I'm new at JavaScript, but if anyone can tell me what i missing I would be grateful.
Basically, I'm trying to test the large value from two input. Here is what I have done so far:
$('#than_stock_submit').click(function() {
var pur_rate = $('#pur_rate input').val(),
sell_rate = $('#sell_rate input').val(),
msg_div = $('#sell_rate .msg');
if(greater_than(sell_rate, pur_rate, msg_div)==false){return false}
});
function greater_than(a, b, msg_div){
msg_div.show().html( '' );
if(a > b){
msg_div.show().html( '<p class="success">Sell Rate is good</p>' );
return true;
} else {
msg_div.show().html( '<p class="error">Sell Rate should be increased</p>' );
return false;
}
}
I have checked with several values. When i tested with the value smaller than 1000 and similar both values like b=500 and a=5000 or b=100 and a=1000, then its working. Other values are not working.
Other tested values are:
- a=751, b=750 and result=true
- a=0751, b=750 and result=false
- a=551, b=750 and result=false
- a=1051, b=750 and result=false
- a=7500, b=750 and result=true
- a=6000, b=600 and result=true
I also checked with console like: console.log(a + b);
The results of console window is like 1000750(when value is like a=1000 & b=750) or 0752750(when value is like a=0752 & b=750).
Thanks.