Here I will explain how to stop form submit on enter in jQuery or prevent form submit on enter key in jQuery or disable form submission on enter key in jQuery.
Description:
In previous articles I explained jQuery get current page url and title, jQuery disable future dates in datepicker, jQuery Get Cursor position, jQuery Bind double click event to button control, jQuery create rounded corners for textbox and many articles relating to JavaScript, jQuery, asp.net codesnippets. Now I will explain how to stop or disable form submission on enter key using jQuery.
In previous articles I explained jQuery get current page url and title, jQuery disable future dates in datepicker, jQuery Get Cursor position, jQuery Bind double click event to button control, jQuery create rounded corners for textbox and many articles relating to JavaScript, jQuery, asp.net codesnippets. Now I will explain how to stop or disable form submission on enter key using jQuery.
If you want to stop form submission we need to write the code like this
|
Suppose if we need to stop form submission on enter key need to write the code like as shown below
Method 1
|
Or we can use Method 2 to disable form submit on enter key
Method 2
$("form").bind("keypress", function (e) { if (e.keyCode == 13) return false; }); |
No comments:
Post a Comment