1. There is only one input [type = "Submit"] in form. test whether the carriage return is automatically submitted.
* Test Result: javascript blocks the form. Submit action. Press enter and do not submit the form automatically. Test browsers: IE6, FF, chrome, opera, and safari;
2. The form contains one input [type = "text"] and one input [type = "Submit"]. test whether the carriage return is automatically submitted.
* Test Result: javascript blocks the form. Submit and BTN. onclick actions:
Press enter and do not automatically submit the form-ie, FF, chrome, opera, Safari;
* Only BTN. onclick behaviors are blocked:
Press enter and do not automatically submit the form-ie, FF, chrome, opera, Safari;
Press enter to automatically submit the form-IE6;
* Only stop form. Submit: do not automatically submit forms-ie, FF, chrome, opera, Safari;
3. There are more than two input [type = "text"] and one input [type = "Submit"] in form.
* Test Result: javascript blocks the form. Submit and BTN. onclick actions:
Press enter. The form cannot be submitted --- IE6, FF, chrome, opera, Safari
* Only BTN. onclick behavior is blocked: the effect is the same as above;
* Only the form. Submit action is blocked: the form cannot be submitted-IE6, FF, chrome, opera, Safari
4. No form, only one input [type = "text"] and one input [type = "Submit"]. use JavaScript to control the jump and test whether the carriage return event is triggered.
* Test Result: press the Enter key to not trigger the jump-ff, chrome, opera, Safari
Press enter to trigger jump behavior-IE6
5. No form, only one input [type = "text"] and one input [type = "button"]. Same as above, test whether to trigger the button click event when you press Enter.
* Test results: the click event cannot be triggered to complete the jump-IE6, FF, chrome, opera, Safari
6. No form, only one input [type = "text"] and one input [type = "Submit"]. Same as above, test whether to trigger the button click event when you press Enter.
* Tests on this page will trigger the submit button in step 4;
7. There are more than two input [type = "text"] and one button in the form. The same as above. The browser behavior when the carriage return is tested.
Button
* Test Result: click the button or press enter, and the form is not submitted. -- ff, chrome, opera, Safari;
* The form is not submitted-IE6;
Summary
1. You can control whether the event submitted by the form is an onsubmit event. Controlling the onsubmit event ensures browser compatibility;
2. The response to form in IE is not "sensitive". When you press enter, The onclick event of submit will not be directly triggered. The onclick event JS cannot be blocked;
3. if you only have one input [type = text] and want to block the default submit behavior when you press enter (for example, Ajax), you can add another input [type = text] in form. display: none.
4. The test environment is IE6, Firefox 3.6, opera 10, chrome 6.0, and Safari 5.0;