I am using one If condition in javascript ,
var iid = "c_poqty_"+itemid;
var calculatedQuantity = document.getElementById(iid).value;
if(! isNaN(actualQuantity)) {
if(actualQuantity >= calculatedQuantity) {
return true;
} else {
alert("You must enter the order qty same or greater than the calculated PO Qty");
document.getElementById(iid).focus();
return false;
}
} else {
alert("Please Enter valid number");
document.getElementById(iid).focus();
return false;
}
Here, calculatedQuantity is always in float and while actualQuantity can be integer,
I have one testcase:
calculatedQuantity = 1.0
actualQuantity = 1
Appreciate for your help!
Actually, I suspect they’re both strings. Certainly
calculatedQtyis, as you’ve retrieved it from thevalueof an input field, and thevalueproperty’s value is always a string. UseparseIntand/orparseFloatso you’re comparing numbers rather than strings.Consider: