Questions

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
}

Your Answers

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

Answers

jansha
Dec 07 11 05:30:05
<html>

google
Oct 24 11 05:09:28
google

Michael
Sep 20 11 03:25:50
Yeah... but it still return TRUE on case of leading Zero, something like  012 and this is may be numeric but it does not have a meaning as a Number.

VBJaw
May 26 11 05:37:38
The above function would not recognise the single digit numbers as numeric. Also would return with error at null length param.

AABB
Jan 26 11 05:08: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
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
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
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
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
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

Tes Pheakdey
Dec 03 10 03:53:06
I love this function.

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