0
我需要验证表单中的一组名称,手机号码字段。为了方便使用服务器端脚本,我使用数组表示法命名了这些字段(即使用方括号)。 此外,下面的相同的html重复自己的次数取决于需要多少记录。jquery验证FIELDS相互依赖的一对
<table width="100%" border="0">
<tr><td class="b_name"><label>Name <sup>*</sup></label></td><td class="b_mobile"><label>Mobile <sup>*</sup></label></td><td class="removetext"><a href="javascript:void(0);" onclick="removebroadcast(this);" id="remove_<?php echo $cnt;?>">Remove</a></td></tr>
<tr><td class="b_name" id="name_<?php echo $cnt;?>"><input type="text" value="" name="broadcast_name[]" class="broadcast_name" /></td><td class="b_mobile" id="mobile_<?php echo $cnt;?>"><input type="text" value="" name="broadcast_mobile[]" class="broadcast_num" /></td><td id="message_<?php echo $cnt;?>"> </td></tr>
</table>
在规则/邮件的一部分,到目前为止,我想出了:
'broadcast_name[]':{required:function(element){
return $(element).parent().next().children('input').val()!='';
}
},
'broadcast_mobile[]':{required:function(element){
return $(element).parent().prev().children('input').val()!='';
}
},
然而,这并不只针对第一套名称/移动领域的工作。我也尝试了一些其他的技巧(例如,使用$ .each类型验证,使用自定义规则函数等),但他们都没有工作。有什么我在这里做错了吗?请帮忙! :(
感谢面具插件,但我实际上已经使用它在手机领域,只是没有想到有必要提供一切的详细信息。 关于提供的解决方案 - 我需要在特定的情况下使用jQuery验证插件,如果以前不明确,请致电 – zarun
欢迎,我想知道为什么我的答案不适合你 –