Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

prevent button from submitting on enter key

function validationFunction() {
  $('input').each(function() {
    ...

  }
  if(good) {
    return true;
  }
  return false;
}

$(document).ready(function() {
  $(window).keydown(function(event){
    if( (event.keyCode == 13) && (validationFunction() == false) ) {
      event.preventDefault();
      return false;
    }
  });
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #prevent #button #submitting #enter #key
ADD COMMENT
Topic
Name
6+2 =