public
Created

  • Download Gist
ensureDigits.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11
function ensureDigits(e) {
e = e || window.event;
var charCode = parseInt(e.keyCode);
var allowableCodes = [48,49,50,51,52,53,54,55,56,57,68,80,96,97,98,99,100,101,102,103,104,105,110,37,39,13,8,188,190,46,113,114,115,116,117,118,119,120,121,122,123, 67, 86];
$('log').update("Ensure Digits:" + charCode);
if (allowableCodes.indexOf(charCode) === -1) {
e.stop();
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.