When a form is submitted without an explicit submit button, such as by pressing Enter or using JavaScript, browsers typically follow specific conventions to identify the default submit button. However, this behavior can vary depending on the browser.
According to the HTML specifications, entering in a non-textarea field within a form should not trigger form submission. However, browsers have implemented their own behavior:
When submitting a form programmatically using formElement.submit(), no submit button is considered successful, and their values are not included in the submitted data. If the submit button's click() method is used, that specific button is considered active.
The specifications do not define a standard for submit button determination when Enter is pressed. Browsers may use heuristics such as:
The default submit button behavior when submitting via Enter or JavaScript is not standardized and varies among browsers. To ensure consistent behavior, it is recommended to avoid relying on specific behaviors and instead use explicit submit buttons whenever possible.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3