Created
May 15, 2015 23:47
-
-
Save michalczukm/c35f4536a55dbb941c42 to your computer and use it in GitHub Desktop.
JS prevent submit form on enter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage | |
FormUtils.preventSubmitOnEnter($('#add_segment_form')); | |
FormUtils = { | |
init: function(){}, | |
preventSubmitOnEnter: function($form){ | |
$form.on("keyup keypress", function(e) { | |
var code = e.keyCode || e.which; | |
if (code == 13) { | |
e.preventDefault(); | |
return false; | |
} | |
}); | |
}, | |
clearSelected: function(selector){ | |
$(selector).find("option").prop("selected", false); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment