我需要jquery验证程序来帮助我检查已填充的输入。验证器出现问题。 验证程序仅工作并检查第一部分,第二部分将无法正确检查
<h1>Form Validation Example</h1>
<form id="registerForm">
<p>
firstname: <input type='text' name='firstname[]' id='firstname' />
</p>
<p>
lastname: <input type='text' name='lastname[]' id='lastname' />
</p>
mobile: <input type='text' name='mobile[]' id='mobile' />
<p>
ic: <input type='text' name='ic[]' id='ic' />
</p>
<br>
<hr>
<p>
firstname: <input type='text' name='firstname[]' id='firstname' />
</p>
<p>
lastname: <input type='text' name='lastname[]' id='lastname' />
</p>
<p>
mobile: <input type='text' name='mobile[]' id='mobile' />
</p>
<p>
ic: <input type='text' name='ic[]' id='ic' />
</p>
<br>
<hr>
<p>
firstname: <input type='text' name='firstname[]' id='firstname' />
</p>
<p>
lastname: <input type='text' name='lastname[]' id='lastname' />
</p>
<p>
mobile: <input type='text' name='mobile[]' id='mobile' />
</p>
<p>
ic: <input type='text' name='ic[]' id='ic' />
</p>
<p>
<input type='submit' name='Submit' value='Submit' />
</p>
</form>
$(document).ready(function() {
$("#registerForm").validate({
rules: {
'firstname[]': {
required: true,
minlength: 1
},
'lastname[]': {
required: true,
minlength: 1
},
'mobile[]': {
required: true,
minlength: 1
},
'ic[]': {
required: true,
minlength: 1
},
},
messages: {
"firstname[]": {
required: 'no firstname'
},
"lastname[]": {
required: 'no lastname'
},
"mobile[]": {
required: 'no mobile'
},
"ic[]": {
required: 'no ic'
},
},
});
});
我需要jquery验证器来检查所有填充的输入 如果姓氏已填写,则姓氏mobile_no && ic不能为空/空。除非名字为空,否则其余的可以为空