parseInt — Javascript

I was quite comforatble after the development got over. UAT was also done well.

But yesterday a user from Kolkatta raised a bug from the UAT url before it goes for production.

Bug was related to validation problem….. i was quite surprised to see such error.

values are coming correct but on checking the comparision its returning true

case look like this:


if(val2>val1) // returning true here (how can this be possible???)

if the value of val2 is more than 3 and less than 9 …… its throwing the validation error

nothing was getting in to my mind

then i realised that the value i am taking from form is the string value, where as i am comparing with int value.

On searching google i found a URL :

Mentioned there about : parseInt ( )

“JavaScript provides a very simple function just fit for our intended use. The signature is quite simple:

var myInteger = parseInt (aString); ”

And this solved my problem at last.

But not so yet…………… i found something relativly good while exploring the site.

The site contains so many good thing relative to almost all field.All you need to explore it once.


एक उत्तर दें

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  बदले )

Google+ photo

You are commenting using your Google+ account. Log Out /  बदले )

Twitter picture

You are commenting using your Twitter account. Log Out /  बदले )

Facebook photo

You are commenting using your Facebook account. Log Out /  बदले )


Connecting to %s