28.10.2015, 00:14
Quote:
|
Code:
var IsNumeric = function(input) {
return (input - 0) == input && (''+input).trim().length > 0;
};
|
You can simply:
Code:
var IsNumeric = function(test) {
return (isNaN(parseFloat(test)) == false && isFinite(test) == true);
}
Quote:
|
print([ IsNumeric("test"), IsNumeric(true), IsNumeric("69"), IsNumeric("19.94") ]); // { 0: false, 1: false, 2: true, 3: true } |


