jQuery Validate 验证 required 问题。 20
我写了验证函数如下:<script>$(function(){$("#btnAdd").click(function(){NeedValidate();});$("#bt...
我写了验证函数如下:
<script>
$(function () {
$("#btnAdd").click(function () {
NeedValidate();
});
$("#btnCan").click(function () {
NoValidate();
});
});
function NeedValidate() {
$("#form1").validate({
rules: {
txtCoId: {
required: true,
maxlength: 3,
max:10000000
},
txtPrincipalId: {
required: true,
maxlength: 10
},
txtFrmid: {
required: true,
maxlength: 4
},
txtAgentId: {
required: true,
maxlength: 10
},
txtKd: {
required: true,
maxlength: 2
}
}
});
}
function NoValidate() {
$("#txtCoId").rules("remove");
$("#txtPrincipalId").rules("remove");
$("#txtFrmid").rules("remove");
$("#txtAgentId").rules("remove");
$("#txtKd").rules("remove");
}
</script>
为什麼验证的时候会提示Please enter a value less than or equal to 0. 我根本没有加MAX或者MIN的验证条件啊。必须像第一个rules那样,手动规定MAX或者MIN才能通过验证,这是为什麼啊。 展开
<script>
$(function () {
$("#btnAdd").click(function () {
NeedValidate();
});
$("#btnCan").click(function () {
NoValidate();
});
});
function NeedValidate() {
$("#form1").validate({
rules: {
txtCoId: {
required: true,
maxlength: 3,
max:10000000
},
txtPrincipalId: {
required: true,
maxlength: 10
},
txtFrmid: {
required: true,
maxlength: 4
},
txtAgentId: {
required: true,
maxlength: 10
},
txtKd: {
required: true,
maxlength: 2
}
}
});
}
function NoValidate() {
$("#txtCoId").rules("remove");
$("#txtPrincipalId").rules("remove");
$("#txtFrmid").rules("remove");
$("#txtAgentId").rules("remove");
$("#txtKd").rules("remove");
}
</script>
为什麼验证的时候会提示Please enter a value less than or equal to 0. 我根本没有加MAX或者MIN的验证条件啊。必须像第一个rules那样,手动规定MAX或者MIN才能通过验证,这是为什麼啊。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询