Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
180
rated 0 times [  183] [ 3]  / answers: 1 / hits: 112177  / 12 Years ago, mon, september 17, 2012, 12:00:00

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 numeric value but not sure if it is a float.');
}


How do I go one step further and convert the string to something that can evaluate to a float?


More From » parsing

 Answers
6

Like this:



if (!isNaN(value) && value.toString().indexOf('.') != -1)
{
alert('this is a numeric value and I'm sure it is a float.');
}​

[#83041] Sunday, September 16, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aidan

Total Points: 72
Total Questions: 95
Total Answers: 121

Location: Uzbekistan
Member since Sat, Feb 27, 2021
3 Years ago
aidan questions
Mon, Oct 11, 21, 00:00, 3 Years ago
Wed, Sep 29, 21, 00:00, 3 Years ago
Sun, Sep 5, 21, 00:00, 3 Years ago
Thu, Jan 16, 20, 00:00, 4 Years ago
;