why code works alert line commented, dont work when not commented?
i want block form submit, allow other functions on enter (example, $.get() in other page). sorry bad english.
$(document).ready(function() { $('#txtpesquisaservidor').keydown(function(event){ if(event.keycode == 13) { //alert('enter!'); event.preventdefault(); return false; } }); });
i'm using jquery 1.6.2.
edit: done! problem alert
https://jsfiddle.net/o0mkjnwk/1/
instead of using .keydown()
method, try using .on('keypress', function...
see following fiddle working example: http://jsfiddle.net/p1agoka1/
edit: see you're using jquery 1.6.2. .on() event handler requires @ least 1.7.0. there reason why you're using such old version?
if have other older code not work newer version of jquery, try implement jquery migrate re-enables older features of jquery not present in up-to-date versions. https://github.com/jquery/jquery-migrate/
Comments
Post a Comment