日期:2014-05-17  浏览次数:20936 次

表单提交问题,急!
<SCRIPT   LANGUAGE= "JavaScript ">
<!--
function   vfs(passform)
{
  if   (out.quantity.value   >   out.mquantity.value)
    {alert   ( "超出库存量 ")
document.out.quantity.focus();
return   false
}
}
-->
</SCRIPT>


<from   action= " "   name= "out "   method= "post "   onsubmit= "return   vf(this) ">
出库量: <input   name= "quantity "   type= "text "   id= "quantity "   value= "2 "   size= "10 ">
库存量: <input   name= "mquantity "   type= "text "   id= "mquantity "   value= "11 "   size= "10 ">
...
</form>

现在的问题:按道理是不会提示 "超出库存量 ",但现在只要出库量大于1就全提示超出库存量 ",只有当出库量等于1的时候才不会提示 "超出库存量 ".
这是什么问题?急!

------解决方案--------------------
<SCRIPT LANGUAGE= "JavaScript ">
function vfs(form){
if (parseInt(form.quantity.value) > parseInt(form.mquantity.value)) {
alert ( "超出库存量 ");
form.quantity.focus();
return false
}
}
</SCRIPT>


<form action= " " name= "out " method= "post " onsubmit= "return vfs(this); ">
出库量: <input name= "quantity " type= "text " id= "quantity " value= "2 " size= "10 ">
库存量: <input name= "mquantity " type= "text " id= "mquantity " value= "11 " size= "10 ">
... <input type= "submit "/>
</form>

------解决方案--------------------
function vfs(passform)
{
if (out.quantity.value > out.mquantity.value)
{alert ( "超出库存量 ")
document.out.quantity.focus();
return false
}
}

在这个函数里面,将out.quantity.value 和out.mquantity.value 转化成数字类型,然后再进行比较