Client side validation for Number values
Hi,
Recently in my project , i needed to validate an input (whether it is a integer or not) on client side.
I tried many codes but they are bit lengthy. Then I encountered the simplest way as given below, which worked.
For any input value, it checks whether it is an Integer or not.
function isInteger(a) { return (!(parseInt(a).toString() == 'NaN')) }
It worked for me ans saves a lot of time.
Hope it helps.
Regards
Vishal Sahu
vishal@intelligrape.com
Hi amit,
Thanks for the suggestion..
i was unaware about isNAN() so i used this..
We also have isNaN() function defined in javascript which returns true if value passed is not a valid number.
Thanks