<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");
}
}
哪位改正一下,谢谢!
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");
}
}
哪位改正一下,谢谢!
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");
}
}
if(document.getElementById("TextBox1").value+document.getElementById("TextBox2").value
结果是两个字符串的拼凑,而不是数字的相加
可以使用parseFloat或者parseInt转换