Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Stop Form being Submitted on Enter Key Press or Disable Form Submit on Enter

Nov 25, 2013
Introduction

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.

If you want to stop form submission we need to write the code like this


$(function () {
$("form").submit(function (e) {
event.preventDefault();
return false;
});
})
Suppose if we need to stop form submission on enter key need to write the code like as shown below

Method 1


$(function () {
$(window).keydown(function (event) {
if (event.keyCode == 13) {
event.preventDefault();
return false;
}
});
});
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;
});

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

1 comments :

Anonymous said...

Hello sir i want the gridview to be load asynchrously

lets i have 1000 line in database so it will show the grid and load parallaly with scroll

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.