/**
 * jQuery validate 自定义验证
 *
 * @author CaiAoLin
 * @date 2017/6/8
 * @version
 */

//检测手机号是否正确
jQuery.validator.addMethod("mobile", function (value, element) {
    let length = value.length;
    let regPhone = /^1([34578]\d)\d{8}$/;
    return this.optional(element) || (length == 11 && regPhone.test(value));
}, "请正确填写您的手机号码");

jQuery.validator.addMethod("ip", function (value, element) {
    if (value === '') {
        return false;
    }
    let regIP = /^(\d{2,})\.(\d+)\.(\d+)\.(\d+)$/;
    return this.optional(element) || regIP.test(value);
}, "请正确填写IP地址");
