<asp:CustomValidator ID="CustomValidator4" runat="server" Display="Dynamic" ClientValidationFunction="checkqty" 
   ErrorMessage="退货总数不能大于出库数量" ValidationGroup="item"></asp:CustomValidator>javascript 可以这样写吗?
 function   checkqty(source,args)     
  {     
if(document.getElementById("TextBox1").value+document.getElementById("TextBox2").value >document.getElementById("TextBox3").value)
{
   alert("aaa")
}
else
{
   alert("bbb");
}
}
哪位改正一下,谢谢!

解决方案 »

  1.   

    要先转成int或是float型
    function checkqty(source, args) {
    if (parseInt(document.getElementById("TextBox1").value) + parseInt(document.getElementById("TextBox2").value) > parseInt(document.getElementById("TextBox3").value)) {
    alert("aaa")
    }
    else {
    alert("bbb");
    }
    }
      

  2.   

    document.getElementById("TextBox1").value默认是字符串类型的,你可以调试下,
    if(document.getElementById("TextBox1").value+document.getElementById("TextBox2").value 
    结果是两个字符串的拼凑,而不是数字的相加
    可以使用parseFloat或者parseInt转换