954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ParseInt textbox text

I take value from textbox as,

var perOfEasyQues = parseInt(document.getElementById("<%=txb_EasyQuesPerc.ClientID%>").value);

but as I put 012 it takes 10.

Can anybody suggest solution over it?

Nitin Daphale
Junior Poster in Training
64 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

Since you are entering value with a preceding 0, the parseInt() function takes it as an octal number. Use the parseInt(, ) function instead with radix set to 10 for decimal numbers as shown below,

var perOfEasyQues = parseInt(document.getElementById("<%=txb_EasyQuesPerc.ClientID%>").value, 10);
parry_kulk
Junior Poster
Team Colleague
167 posts since Jan 2007
Reputation Points: 26
Solved Threads: 41
 

Since you are entering value with a preceding 0, the parseInt() function takes it as an octal number. Use the parseInt(, ) function instead with radix set to 10 for decimal numbers as shown below,

var perOfEasyQues = parseInt(document.getElementById("<%=txb_EasyQuesPerc.ClientID%>").value, 10);


Thanks parry_kulk for your quick reply.

Nitin Daphale
Junior Poster in Training
64 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: