Validating Text Field for Only Numbers

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;
}



Related Topic What are all Common use of SSH for UNIX and Linux systems
How to get the HTTP Cookie Value
Javascript Spell Checker Embedded Code, Text Area Object
How to Create String Color and Dimension Layouts with Simple Value Components
List of Mysql Error Code and Description

nScraps.com 2011   Privacy Policy  Terms of Service  Feedback