cancel
Showing results for 
Search instead for 
Did you mean: 

isNaN is not working in IE

mcasanket
Champ on-the-rise
Champ on-the-rise
HI All,

  In one requirement I need to check the number for validation.
  I am using isNan() function but it is not working with IE 😞
  Please help. I am using IE 7.

Thanking you!
2 REPLIES 2

lotharmärkle
Champ in-the-making
Champ in-the-making
I understood your javascript is running on the browser - so it is not a repository (sever side) script.

One more robust solution maybe is YAHOO.lang.isNumber(myNumber), which is available if you are using share. http://developer.yahoo.com/yui/docs/YAHOO.lang.html#method_isNumber

Personally I also use a regex for text:
/^\d+$/.test(myNumber) === true

I suggest you search ob stackoverflow.com for other examples.

mcasanket
Champ on-the-rise
Champ on-the-rise
Hi Lothar,
  Thanks for your reply. But I have used one function that I got from Google search… and it solved my problem.

function isNumeric(val) {
    var numeric = true;
    var chars = "0123456789.-,+";
    var len = val.length;
    var char = "";
    for (i=0; i<len; i++) { char = val.charAt(i); if (chars.indexOf(char)==-1) { numeric = false; } }
    return numeric;
}


One more robust solution maybe is YAHOO.lang.isNumber(myNumber), which is available if you are using share. http://developer.yahoo.com/yui/docs/YAHOO.lang.html#method_isNumber

Thanking you!