You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.0 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

var errIcon = "<i class='fa fa-times-circle'></i> ";
$.validator.setDefaults({
highlight: function (element) {
$(element).closest('.form-group').removeClass('has-success').addClass('has-error');
},
success: function (element) {
element.closest('.form-group').removeClass('has-error').addClass('has-success');
},
errorElement: "span",
errorPlacement: function (error, element) {
if (element.is(":radio") || element.is(":checkbox")) {
error.appendTo(element.parent().parent().parent());
} else {
error.appendTo(element.parent());
}
},
errorClass: "help-block m-b-none",
validClass: "help-block m-b-none"
});
$(function () {
jQuery.validator.addMethod("isMobile", function (value, element) {
var regex = /^1[3-9]{1}\d{9}$/;
return this.optional(element) || (regex.test(value));
}, "请输入正确的手机号码");
$.validator.addMethod("strongPwd", function (value, element, params) {
return checkPwdStrong(value)
}, "请输入与6-16位密码同时包含大小写字母和数字");
$.validator.addMethod("hasCnWords", function (value, element, params) {
var reg = new RegExp("[^\x00-\xff]", "g");
if (value.match(reg)) {
return false
}
return true
}, "不能含有中文和双字节字符");
jQuery.validator.addMethod("tempset_chk", function (value, element) {
var tel = /^-?[0-9]{1,2}.[0-9]{1}$/;
return this.optional(element) || (tel.test(value));
}, "温度设置应为三位(小数点后一位,前两位)");
jQuery.validator.addMethod("sft_check_rows_len", function (value, element) {
var arr = value.split('\n');
if (arr.length > 5) {
return false;
}
for (var idx = 0; idx < arr.length; arr++) {
if (arr[idx].length > 35) {
return false;
}
}
return true;
}, "不能超过5行且每行不超35个字符");
})