I am passing in a parameter called value. I\'d like to know if value is a float. So far, I have the following:
if (!isNaN(value))
{
alert(\'this is a num
To check if a string is a float (avoid int values)
function isFloat(n) {
if( n.match(/^-?\d*(\.\d+)?$/) && !isNaN(parseFloat(n)) && (n%1!=0) )
return true;
return false;
}
var nonfloat = isFloat('12'); //will return false
var nonfloat = isFloat('12.34abc'); //will return false
var float = isFloat('12.34'); //will return true