Skip to content

Instantly share code, notes, and snippets.

@SamWM
Created October 21, 2013 14:10
Show Gist options
  • Save SamWM/7084519 to your computer and use it in GitHub Desktop.
Save SamWM/7084519 to your computer and use it in GitHub Desktop.
$.fn.intcheck = function () {
return this.bind("keyup", function () {
this.value = this.value.replace(/[^0-9]/g, '');
if (isNaN(this.value)) {
while (isNaN(this.value)) {
var len = this.value.length;
if (len < 1) break;
this.value = this.value.substring(0, len - 1);
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment