[Javascript] parseInt glitch

tyson twenger at vltool.com
Tue Aug 16 15:47:24 CDT 2005


I'm using javascript to validate the syntax of a "date" input by the 
user.  I split the string variable by "/" and then check each month, 
day, year...  Anyways,  I noticed that when I use the function 
parseInt(month), I get an error if its higher than '07'.  For example:
       parseInt('01') = 1
       parseInt('02') = 2
       parseInt('07') = 7 
 but parseInt('08') = 0
and parseInt('09') = 0

This problem only occurs if there's a "0" in front of the number.   If I 
do parseInt('8') it works fine, but parseInt('08') doesn't.  Does 
anybody know why it does this?  I don't want to mask out the "0" if I 
don't have to, but that looks like the only option now.  I tested this 
on a command line, so I know its not just my program.  Any  help would 
be appreciated!

  -Tyson



More information about the Javascript mailing list