Hi all,
Following is some code. Please run this and see if you get the same result I am getting.
Note that there are four snippets. In each the birthdate is incremented by one, starting with Dec. 6 and going to Dec. 9 (12091995).
For each snippet are two alerts. The first shows substr(2,2). The second shows the parse integer of substr. 8 messages are displayed. I get
06
6
07
7
08
0
09
0
The issue - 08 and 09 are not treated the same as 06 and 07 (or as 05, 04, etc.). Anyone know why this happens? Is this a bug in javascript? Here is the code:
<HTML>
<HEAD>
<TITLE></TITLE>
<Script Type="text/javascript">
function test1()
{
var birthdate1="12061995"
alert (birthdate1.substr(2,2))
dd1=parseInt(birthdate1.substr(2,2))
alert (dd1)
var birthdate2="12071995"
alert (birthdate2.substr(2,2))
dd2=parseInt(birthdate2.substr(2,2))
alert (dd2)
var birthdate3="12081995"
alert (birthdate3.substr(2,2))
dd3=parseInt(birthdate3.substr(2,2))
alert (dd3)
var birthdate4="12091995"
alert (birthdate4.substr(2,2))
dd4=parseInt(birthdate4.substr(2,2))
alert (dd4)
}
</Script>
</HEAD>
<BODY BGCOLOR="#EBEEEE">
<input type="button" onclick="test1()" value="Click" />
</BODY>
</HTML>
Following is some code. Please run this and see if you get the same result I am getting.
Note that there are four snippets. In each the birthdate is incremented by one, starting with Dec. 6 and going to Dec. 9 (12091995).
For each snippet are two alerts. The first shows substr(2,2). The second shows the parse integer of substr. 8 messages are displayed. I get
06
6
07
7
08
0
09
0
The issue - 08 and 09 are not treated the same as 06 and 07 (or as 05, 04, etc.). Anyone know why this happens? Is this a bug in javascript? Here is the code:
<HTML>
<HEAD>
<TITLE></TITLE>
<Script Type="text/javascript">
function test1()
{
var birthdate1="12061995"
alert (birthdate1.substr(2,2))
dd1=parseInt(birthdate1.substr(2,2))
alert (dd1)
var birthdate2="12071995"
alert (birthdate2.substr(2,2))
dd2=parseInt(birthdate2.substr(2,2))
alert (dd2)
var birthdate3="12081995"
alert (birthdate3.substr(2,2))
dd3=parseInt(birthdate3.substr(2,2))
alert (dd3)
var birthdate4="12091995"
alert (birthdate4.substr(2,2))
dd4=parseInt(birthdate4.substr(2,2))
alert (dd4)
}
</Script>
</HEAD>
<BODY BGCOLOR="#EBEEEE">
<input type="button" onclick="test1()" value="Click" />
</BODY>
</HTML>