Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery验证相互依赖的字段对_Jquery_Validation - Fatal编程技术网

jquery验证相互依赖的字段对

jquery验证相互依赖的字段对,jquery,validation,Jquery,Validation,我需要验证表单中的一组姓名、手机号码字段。为了方便使用服务器端脚本,我用数组表示法(即方括号)命名了字段。 此外,下面的同一个html会重复多次,具体取决于需要多少条记录 <table width="100%" border="0"> <tr><td class="b_name"><label>Name <sup>*</sup></label></td><td class="b_mobile"

我需要验证表单中的一组姓名、手机号码字段。为了方便使用服务器端脚本,我用数组表示法(即方括号)命名了字段。 此外,下面的同一个html会重复多次,具体取决于需要多少条记录

<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;?>">&nbsp;</td></tr>
</table>

但是,这仅适用于第一组名称/移动字段。我还尝试了其他一些技巧(例如,使用$。每个类型验证,使用自定义规则函数等),但它们似乎都不起作用。这里有什么我做错的吗?请帮忙(

您可能想查看电话字段:

你不能做点像这样的事吗

$('form').submit(function(e){
    var errors = false;
    $(this).find('input').each(function(){
        if($(this).val() === ''){
            errors = true;
        }
    });
    if(errors){
        e.preventDefault();
        alert('errors exist');
    }
});

感谢mask插件,但实际上我一直在电话领域使用它,只是不认为有必要提供所有细节。关于提供的解决方案,我需要具体使用jquery验证插件,如果您之前不清楚,我深表歉意。不客气,我想知道为什么我的答案对您不起作用霍夫
$('form').submit(function(e){
    var errors = false;
    $(this).find('input').each(function(){
        if($(this).val() === ''){
            errors = true;
        }
    });
    if(errors){
        e.preventDefault();
        alert('errors exist');
    }
});