javascript - prevent @ to be entered into input field? -
i want prevent @
entered input
. doesn't work, idea why?
$(function() { $(document).on('keyup', '[placeholder="x"]', function() { if (event.keycode === 64) { event.preventdefault(); } }); })
you need pass parameter event
function:
$(document).on('keypress', '[placeholder="x"]', function(event) { /*...*/ });
i suggest use event.which
instead of event.keycode
better compatibility. here's updated fiddle. have used keypress
event instead of keyup
.
Comments
Post a Comment