Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.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
Javascript Jquery验证程序为复选框添加方法验证_Javascript_Jquery - Fatal编程技术网

Javascript Jquery验证程序为复选框添加方法验证

Javascript Jquery验证程序为复选框添加方法验证,javascript,jquery,Javascript,Jquery,如何将这样的函数添加到jQuery.validator.addMethod中: if (theForm.chk_ccd.checked && (! theForm.chk_ccd_pos [0].checked) && (! theForm.chk_ccd_pos [1].checked) && (! theForm.chk_ccd_pos [2].checked)) { window.alert ('P

如何将这样的函数添加到jQuery.validator.addMethod中:

if (theForm.chk_ccd.checked            &&
   (! theForm.chk_ccd_pos [0].checked) &&
   (! theForm.chk_ccd_pos [1].checked) &&
   (! theForm.chk_ccd_pos [2].checked))
{
  window.alert ('Please select data from the \"CCD Position\" field.');
  theForm.chk_ccd_pos [0].focus ();
  return;
}
以及此处的验证功能:

function ActionAdd (theForm)
    {
        $("#form").validate
        ({
            rules:
            {
                de_no: "required",
                de_name: "required",
                product_name: "required",
                plabel_no: "required",
            },
            messages:
            {
                de_no: "<div class='error'>Please provide Part No.</div>",
                de_name: "<div class='error'>Please provide Model Name</div>",
                product_name: "<div class='error'>Please provide Product Name</div>",
                plabel_no: "<div class='error'>Please provide Part No. (Pack Label)</div>",
            }
        });
    }
函数操作添加(表单)
{
$(“#表格”)。验证
({
规则:
{
de_no:“必需”,
de_名称:“必需”,
产品名称:“必需”,
plabel_no:“必需”,
},
信息:
{
de_编号:“请提供零件号”,
de_名称:“请提供型号名称”,
产品名称:“请提供产品名称”,
零件号:“请提供零件号(包装标签)”,
}
});
}
请任何人帮忙,我一直在处理那个案子。 谢谢

<form id="myForm" action="">
<br />check 1?
<input type="checkbox" id="check0" name="check0" class="chkgroup"/>
<br />check 2?
<input type="checkbox" id="check1" name="check1" class="chkgroup"/>
<br />check 3?
<input type="checkbox" id="check2" name="check2" class="chkgroup"/>
<br />
<input type="submit" />
$(function () {
    jQuery.validator.addMethod("checkboxCheck", function(value, element,params) {
            return $(params[0]+':checked').length > 0;
    });
    $("#myForm").validate({

        rules: {
            check0:{
                checkboxCheck:['.chkgroup'],
            },
        },
        messages: {
            check0:{
                checkboxCheck: "check your checkbox",
            },
        },
        submitHandler: function(form) {
            // ajax goes here
            alert("valid form");
            return false;
        }
    });

});