The information in this article applies to:
SYMPTOMSWhen a string value that contains leading zeros is passed to the parseInt() JScript function, parseInt will return 0 for "08" and "09". CAUSEIn JavaScript placing a leading 0 in front of a number designates that number as octal. In octal, there is no 08 or 09. Therefore, these numbers are interpreted as 0. RESOLUTIONYou must remove the leading zeros before calling parseInt. Here is the code for the workaround:
STATUSThis behavior is by design. MORE INFORMATIONSteps to Reproduce BehaviorThe following Web page demonstrates this problem. This Web page contains a text box. When focus is shifted away from the edit box by pressing the TAB key, the parseInt() function is called with the value that was entered into the text box. The value returned from parseInt() is then displayed in an alert box. If you enter "08" or "09" into the text box, parseInt() returns a value of 0.
The following JScript code demonstrates the workaround for this problem.
Additional query words:
Keywords : kbIE400 kbIE401 kbJScript300 kbScript kbIE401sp1 kbIE500 |
Last Reviewed: July 12, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |