HTML代码
<div class="layui-form-item " id="posttype">
<div class="layui-input-inline " >
<input type="checkbox" name="posttype" title="短信 " lay-skin="primary" lay-verify="fuxuan" value="1">
</div>
<div class="layui-input-inline " >
<input type="checkbox" name="posttype" title="邮件" lay-skin="primary" lay-verify="fuxuan" value="2" >
</div>
<div class="layui-input-inline ">
<input type="checkbox" name="posttype" title="企业微信 " lay-skin="primary" lay-verify="fuxuan" value="3" >
</div>
</div>
js代码
//自定义验证规则
form.verify({
passval:[
/^[\S]{6,12}$/,
'密码必须6到12位,且不能出现空格'
],
fuxuan:function (value, item) {
//console.log($('#posttype input:checked').size());
if($('#posttype input:checked').size()==0){
return "请至少选择一个发送方式";
}
}
});