Hi,
Usage : onkeypress ="return numbersonly(event);"
function numbersonly(e) {
var keynum
var keychar
var numcheck
if(window.event) { // IE
var code = window.event;
keynum = code.keyCode
} else if(e.which) {// Netscape/Firefox/Opera
keynum = e.which
}
if (keynum == 99) return true;
if (keynum == 118) return true;
//if (keynum == 42) return true;
if (keynum == 8 || keynum == 13 ) return true;
if (keynum < 48 || keynum > 57 ) return false;
}
No comments:
Post a Comment