![]() |
Check a Field for an Integer Value
|
||||||||||||||
|
Home > Toys > Here This JavaScript program is utilized to validate that a numeric field is either numeric and (optionally) is within a specific numeric range. When data is changed in any field so coded, CKint() is called to see if the data is first and foremost a number. If it fails that, a JavaScript 'alert()' box pops up to indicate the error. If the entered data is actually a number, and the call to CKint() specifies a range, the number entered is compared to the range. If the entered number is outside the range, then a JavaScript 'alert()' box pops up to inform the user of this error.
When you look at the source to this document, look over the <input ...> tags for the 'isnumeric' and 'isrange' input fields below. Each has a JavaScript 'onChange=' event handler that is specific to the given input field. The first argument to CKint() is always 'this.value'. If you do not want range checking to occur, simply set the second and third values to '0'. If you do want range checking, the second value is the minimum value, the third is the maximum. |
||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
||||||||||||||