Q&A Categories

  • No categories

How to test if a string can be converted to a number in javascript ?

Feb

15

2013

Testing if a string can be converted to a number in javascript ?

In: Uncategorized Asked By: [Jennifer] (Anonymously)
vote
Answer #1

You have to create a function which will return true or false upon testing the string value.
Here’s an example I found on the net working in all situations:

function isNumber(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}

Answers Answered By: andrew [ Grey Star Level]

Answer this Question

Enter name & email to post an Answer. You can also Login / Join us

For a better management of this site please consider Logging in / Joining us before posting a Question. It makes everithing easier for us.

Please enter the captcha code bellow.
Logged in users don't have to use captchas. Don't have an account? Join us!

 

Link Exchange:

You can add url to the best of the internet directory. Our url is added under Reference Directory
HE Blog Directory WEB LOG SHOWWEB LOG SHOW