[leglug-users] javaScript, IIS_mySQL 2

Chady Kassouf chady.kassouf at gmail.com
Wed Jun 28 04:30:43 EDT 2006


On 6/28/06, Nabil Kabalan <nabillu at hotmail.com> wrote:
[snip]

and another question
> can i use parseInt inside an if statment, i mean in case the result was
> NaN
> would it return false?
> like:
> var temp=document.formName.elementName
> if (parseInt(temp, 2))
> {
> alert("A valid number")
> }
> else
> alert("NOT a Valid number")
>
> would somethin like this work?
>

It will work because if there is a number, parseInt will return it, thus
it's a true value.
the only time this will not work as expected is if the form element contains
a "0"
parseInt will return it, but 0 in the if will end up as a false and will be
rejected.

here's a dirty hack around it.  (untested)

if (parseInt(temp,2)+"" == "NaN")
    alert("Not a valid Number")
else
    alert("A valid Number")




-- 
Chady 'Leviathan' Kassouf
http://chady.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.leglug.org/pipermail/leglug-users/attachments/20060628/d7ce6297/attachment.htm 


More information about the leglug-users mailing list