Posted By

smithbjames on 07/24/10


Tagged

form javascript textmate jquery


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

rageit


Prevent Enter from Submitting Form (jQuery)


 / Published in: jQuery
 

  1. $('.no-enter').keypress(function(e){ //Stop form fields with class 'no-enter' from submitting the form when the user presses enter
  2. if(e.which == 13){ //Identifies the enter key as the key pressed
  3. e.preventDefault(); //Stops the enter key from performing default function
  4. alert('no enter'); //Put whatever you want to happen here
  5. }
  6. });

Report this snippet  

You need to login to post a comment.