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:

val1=2100;
val2=3;

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

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 : http://www.suite101.com/article.cfm/javascript/60295

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.

Published in: on May 1, 2007 at 12:20 pm

The URI to TrackBack this entry is: http://amijha.wordpress.com/2007/05/01/parseint-javascript/trackback/

RSS feed for comments on this post.

Leave a Comment