javascript bigger than if statement not working correctly -
i no expert in javascript, hope can me out.
i have following code, reason thinks statement true
delvnum=document.getelementbyid("deliverynum").value; delvqty=document.getelementbyid("delvqty"+id).value; orderqty=document.getelementbyid("orderqty"+id).value; if (delvqty>orderqty) { alert("can't deliver more " + orderqty + ", trying deliver " + delvqty + ". please fix!"); document.getelementbyid("delvqty"+id).focus(); return; }
the error message show quantity of each var, , correctly being passed through.
you comparing strings , not numbers.
use parseint or parsefloat
if (parsefloat(delvqty)>parsefloat(orderqty))
or
if (parseint(delvqty,10)>parseint(orderqty,10))
Comments
Post a Comment