Evaluate NaN

Results 1 to 3 of 3

Thread: Evaluate NaN

  1. #1
    Join Date
    Dec 1969

    Default Evaluate NaN

    In the code below, the first alert displays NaN but the second alert does not fire. What is the proper way to evaluate NaN?<BR><BR>var num = parseInt(arguments.Value);<BR>alert (num);<BR>if (num == "NaN") {<BR> alert(num);<BR> arguments.IsValid = false;<BR>}

  2. #2
    Join Date
    Dec 1969

    Default isNaN (eop)


  3. #3
    Join Date
    Dec 1969

    Default NaN is *NOT* a string...

    ...it&#039;s a *condition*. Yes, when you alert() it or otherwise FORCE it to be converted to a string then it comes out as the string NaN.<BR><BR>To test for it, use the <BR> isNaN( ... ) <BR>function.<BR><BR>if ( isNaN( num ) ) <BR>{<BR> alert(arguments.Value + &#039; is not a number&#039;);<BR> arguments.IsValid = false;<BR>}<BR><BR>No point in doing alert(num) as you know the only thing that will show is "NaN".<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts