...

View Full Version : type verification



eranwein
01-28-2006, 02:20 AM
is there a function that checks if the value of givven string is a "float"?

fci
01-28-2006, 04:27 AM
there may be a better way than this, but..

function is_float(str) {
return /^[0-9]+\.[0-9]+$/.test(str);
}

eranwein
01-28-2006, 05:34 AM
it works...:thumbsup:

is there a way to know how many digits are to the right of the point.

subhailc
01-28-2006, 08:02 AM
function countdecs(a){return String(a).split(".").pop().split("").length;}
alert(countdecs(234.2309482309482309));



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum