Your Open Source

 
Related Posts

IsNumeric and IsNan function in JS

IsNumeric function used to check the numeric or not.

isNaN function used to check the value is a number or not. If the values is numeric its return true else returned false.


Syntax :

bool IsNumeric(string)


Code :
function IsNumeric(val) {

if (isNaN(parseFloat(val))) {
return false;
}
return true
}

  • hits 48539
  • datetime Aug 28 08 03:26:52
  • author Sekar
  • rating

Rating : 12345
Tags :- JavaScript

Answers

Grumpy Buffalo
Jul 21 10 07:33:30
Significant mistake on the page - isNaN returns true if the value passed in is NOT numeric (as expected), not what this page says:

"isNaN function used to check the value is a number or not. If the values is numeric its return true else returned false."

gummed
Dec 06 09 02:30:02
This function is much better:

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


See http://dl.dropbox.com/u/35146/js/tests/isNumber.html
for details

mugdha
Oct 10 09 12:07:55

nice tution

Your Name:
Your Answers :
<> is a code tag
Preview
Enter the verification code: