Cancel a keystroke in jQuery
Posted
by Jimbo
on Stack Overflow
See other posts from Stack Overflow
or by Jimbo
Published on 2010-05-31T15:19:24Z
Indexed on
2010/05/31
15:23 UTC
Read the original article
Hit count: 235
Is is possible (cross-browser compatible) to CANCEL a keystroke after a user has made it (for example on a textbox)
The code I currently use edits the textbox value after the keystroke has been displayed:
$('.number').keypress(function() {
this.value = this.value.replace(/[^0-9\.]/g, '');
});
© Stack Overflow or respective owner