-1
我有两个文本框,我正在应用jQuery验证规则。我已经这样做了,它工作正常,但我想从两个框中选择提交像我想要至少在框中归档。如果我留空他们都应该给予错误所以如何运用这一点,我在下面如何使用jQuery验证应用可选验证
<script>
$.validator.addMethod("box_not_same", function(value, element) {
return $('#box2').val() == value;
}, "box1 value and box2 value cannot be same..");
$("#f1").validate({
rules: {
box1: "required",
box2: {
required: true,
Password_not_same:true
}
},
messages: {
box1: "Enter box1 value",
box2: {
required : "Enter value in box2",
box_not_same:"box1 value and box2 value cannot be same.",
}
}
});
</script>
<input id="box1" name="box1" value=""/>
<input id="box2" name="box2" value=""/>
什么是'Password_not_same'? – Bergi
请修正您的拼写和语法,以便我们可以更好地了解您想要的内容。 – Sparky