Showing posts with label regex number. Show all posts
Showing posts with label regex number. Show all posts

Thursday, August 25, 2011

isNumeric javascript

There is no predefined function to test ,if a value is numeric .
This function helps to check whether a variable's value is numeric or not.


var isNumeric = function(x) {
// returns true if x is numeric and false if it is not.
var RegExp = /^(-)?(\d*)(\.?)(\d*)$/;
return String(x).match(RegExp);
}


Hope this helps!