js代码
// 手机号码验证
jQuery.validator.addMethod("isMobile", function(value, element) {
var length = value.length;
var mobile = /^(1)\d{10}$/;
return this.optional(element) || (length == 11 && mobile.test(value));
}, "请正确填写手机号码"); $("#jsForm").validate({ focusInvalid: false,
submitHandler: function (form) { form.submit();
}
});
Html 部分
<div class="form-group">
<div class="col-lg-2 control-label text-right">手机</div>
<div class="col-lg-10">
<input type="text" class="form-control" name="cell_phone"
value="<?= $data['cell_phone'] ?>" required data-rule-isMobile="true" data-msg-required="*手机号不能为空">
</div>
</div>