Number Only Text Field
The below function for allowing only numbers to text field is written in Javascript. The function is used in most of the cases when validating text field for numbers
Javascript Code for Validating Text Field for Only Numbers
function onlyNumbers(evt) {
var e = evt
if(window.event){ // IE
var charCode = e.keyCode;
} else if (e.which) { // Safari 4, Firefox 3.0.4 and later versions
var charCode = e.which
}
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}