-1

I have 2 variables a and b in JavaScript. I have one condition:

 if(a>b){alert('error')}

This condition is working perferctly fine. But when b>=1 lakh, control is going inside if irrespective of the value of a. What can be the possible solution?

Sample code:

    var a = amt1;
    var b = amt2;
    if(a>b){
    alert('error');
    }

error is thrown when b>=100000 irrespective of value of a.

4

1 回答 1

1

Check if you have a or b as String..if so u could handle it with following code:

var a = parseFloat(amt1);
var b = parseFloat(amt2);
if(a>b){
   alert('error');
}
于 2013-10-30T06:59:24.470 回答