Preventing non-numeric values being entered into a field.

mike55

Contributor
Joined
Mar 26, 2004
Messages
727
Location
Ireland
Hi,

Is there any javascript available whereby I can prevent the user from entering non-numeric values into a textfield as they are typing data into the field. Or is this requirement undoable.

Mike55.
 
JS has isNaN() function, Is Not a Number, you can use this on a blur of the textbox or keydown.

if (isNaN('test')) {
alert('This is not a number!');
}
 
Back
Top