JQuery.validate

jQuery.validator.addMethod("checkLoginUserName",
function(h, j) {
    var g = false;
    var f = /^[A-Za-z]{1}([A-Za-z0-9]|[_]){0,29}$/;
    var i = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
    if (f.test(h) || i.test(h)) {
        g = true
    }
    return this.optional(j) || g
},
"wrong username.");




jQuery.validator.addMethod("requiredUserName",
function(c, d) {
    if ("用户名/邮箱" == c) {
        return false
    }
    if (c == null || "" == c) {
        return false
    }
    return true
},
"wrong username.");



jQuery.validator.addMethod("requiredSchoolName",
function(c, d) {
    if ("简码/汉字" == c) {
        return false
    }
    if (c == null || "" == c) {
        return false
    }
    return true
},
"wrong schoolname.");





jQuery.validator.addMethod("randCodeRequired",
function(c, d) {
    $("#i-ok").css("display", "none");
    return c.length > 0
},
"验证码错误!");
jQuery.validator.addMethod("randCodeFormat",
function(f, d) {
    $("#i-ok").css("display", "none");
    var e = /^[a-zA-Z0-9]+$/;
    return this.optional(d) || e.test(f)
},
"验证码错误!");
jQuery.validator.addMethod("randCodeLength",
function(c, d) {
    $("#i-ok").css("display", "none");
    return c.length == 4
},
"验证码错误!.");
jQuery.validator.addMethod("integrationCheck",
function(d, e) {
    var f = /^\d{6}$/;
    return this.optional(e) || f.test(d)
},
"wrong integrationpassword");








jQuery.validator.addMethod("integrationPwdCheck",
function(d, e, f) {
    if ($("#" + f[0]).val() == $("#" + f[1]).val()) {
        return true
    }
    return false
},
"两次输入密码不一致!.");









jQuery.validator.addMethod("checkRandCode",
function(h, e, g) {
    var f = true;
    if (h && h.length == 4) {
        $.ajax({
            url: ctx + "passcodeNew/checkRandCodeAnsyn",
            type: "post",
            data: {
                randCode: h,
                rand: g
            },
            async: false,
            success: function(a) {
                if (a.data == "N") {
                    f = false;
                    $("#i-ok").css("display", "none")
                } else {
                    f = true;
                    $("#i-ok").css("display", "block")
                }
            }
        })
    } else {
        f = false;
        $("#i-ok").css("display", "none")
    }
    return f
},
"验证码错误!.");









jQuery.validator.addMethod("validateUsersName",
function(c, d) {
    return this.optional(d) || /^[A-Za-z]{1}([A-Za-z0-9]|[_]){0,29}$/.test(c)
},
"用户名只能由字母、数字或_组成");









jQuery.validator.addMethod("checkWriteSpace",
function(f, d) {
    for (var e = 0; e < f.length; e++) {
        if (f.charCodeAt(e) == 32) {
            return false
        }
    }
    return true
},
"contain writespace");











jQuery.validator.addMethod("validateRandCode",
function(c, d) {
    return this.optional(d) || /^[a-zA-Z0-9]+$/.test(c)
},
"验证码错误!.");









jQuery.validator.addMethod("checkPassward",
function(j, f, h) {
    var i = true;
    for (var g = 0; g < j.length; g++) {
        if (j.charCodeAt(g) == 39 || j.charCodeAt(g) == 60 || j.charCodeAt(g) == 62) {
            i = false
        }
        if (!i) {
            break
        }
    }
    return this.optional(f) || i
},
"Passward wrong");











function validateSecIdCard(k) {
    var l = 0;
    var i = k;
    var m = {
        11 : "北京",
        12 : "天津",
        13 : "河北",
        14 : "山西",
        15 : "内蒙",
        21 : "辽宁",
        22 : "吉林",
        23 : "黑龙",
        31 : "上海",
        32 : "江苏",
        33 : "浙江",
        34 : "安徽",
        35 : "福建",
        36 : "江西",
        37 : "山东",
        41 : "河南",
        42 : "湖北",
        43 : "湖南",
        44 : "广东",
        45 : "广西",
        46 : "海南",
        50 : "重庆",
        51 : "四川",
        52 : "贵州",
        53 : "云南",
        54 : "西藏",
        61 : "陕西",
        62 : "甘肃",
        63 : "青海",
        64 : "宁夏",
        65 : "新疆",
        71 : "台湾",
        81 : "香港",
        82 : "澳门",
        91 : "国外"
    };
    if (!/^\d{17}(\d|x)$/i.test(i)) {
        return false
    }
    i = i.replace(/x$/i, "a");
    if (m[parseInt(i.substr(0, 2))] == null) {
        return false
    }
    var n = i.substr(6, 4) + "-" + Number(i.substr(10, 2)) + "-" + Number(i.substr(12, 2));
    var j = new Date(n.replace(/-/g, "/"));
    if (n != (j.getFullYear() + "-" + (j.getMonth() + 1) + "-" + j.getDate())) {
        return false
    }
    for (var d = 17; d >= 0; d--) {
        l += (Math.pow(2, d) % 11) * parseInt(i.charAt(17 - d), 11)
    }
    if (l % 11 != 1) {
        return false
    }
    return true
}














function validateFirIdCard(k) {
    var l = 0;
    var i;
    var m = {
        11 : "北京",
        12 : "天津",
        13 : "河北",
        14 : "山西",
        15 : "内蒙",
        21 : "辽宁",
        22 : "吉林",
        23 : "黑龙",
        31 : "上海",
        32 : "江苏",
        33 : "浙江",
        34 : "安徽",
        35 : "福建",
        36 : "江西",
        37 : "山东",
        41 : "河南",
        42 : "湖北",
        43 : "湖南",
        44 : "广东",
        45 : "广西",
        46 : "海南",
        50 : "重庆",
        51 : "四川",
        52 : "贵州",
        53 : "云南",
        54 : "西藏",
        61 : "陕西",
        62 : "甘肃",
        63 : "青海",
        64 : "宁夏",
        65 : "新疆",
        71 : "台湾",
        81 : "香港",
        82 : "澳门",
        91 : "国外"
    };
    if (k.length == 15) {
        i = idCardUpdate(k)
    } else {
        i = k
    }
    if (!/^\d{17}(\d|x)$/i.test(i)) {
        return false
    }
    i = i.replace(/x$/i, "a");
    if (m[parseInt(i.substr(0, 2))] == null) {
        return false
    }
    var n = i.substr(6, 4) + "-" + Number(i.substr(10, 2)) + "-" + Number(i.substr(12, 2));
    var j = new Date(n.replace(/-/g, "/"));
    if (n != (j.getFullYear() + "-" + (j.getMonth() + 1) + "-" + j.getDate())) {
        return false
    }
    for (var d = 17; d >= 0; d--) {
        l += (Math.pow(2, d) % 11) * parseInt(i.charAt(17 - d), 11)
    }
    if (l % 11 != 1) {
        return false
    }
    return true
}














function idCardUpdate(j) {
    var h;
    var k = /^(\d){15}$/;
    if (k.test(j)) {
        var l = 0;
        var i = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
        var m = new Array("1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2");
        j = j.substr(0, 6) + "19" + j.substr(6, j.length - 6);
        for (var n = 0; n < j.length; n++) {
            l += parseInt(j.substr(n, 1)) * i[n]
        }
        j += m[l % 11];
        h = j
    } else {
        h = "#"
    }
    return h
}












jQuery.validator.addMethod("checkBorth",
function(i, j) {
    var d = i;
    if (d == "") {
        return true
    } else {
        var g = d.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
        if (g == null) {
            return false
        }
        var h = new Date(g[1], g[3] - 1, g[4]);
        return (h.getFullYear() == g[1] && (h.getMonth() + 1) == g[3] && h.getDate() == g[4])
    }
},
"日期格式不合法");











jQuery.validator.addMethod("byteRangeLength",
function(i, f, h) {
    var j = i.length;
    for (var g = 0; g < i.length; g++) {
        if (i.charCodeAt(g) > 127) {
            j++
        }
    }
    return this.optional(f) || (j >= h[0] && j <= h[1])
},
"length wrong");









jQuery.validator.addMethod("checkNameCharBlank",
function(h, e, g) {
    var f = g.split("@");
    if ($("#" + f[1]).val() == "") {
        return true
    } else {
        if ($("#" + f[0]).val() == "1" || $("#" + f[0]).val() == "2") {
            return this.optional(e) || /^[a-zA-Z·..\u4E00-\u9FA5]+$/.test(h)
        } else {
            return this.optional(e) || /^[a-z A-Z·..\u4E00-\u9FA5]+$/.test(h)
        }
    }
},
"wrong name.");










jQuery.validator.addMethod("checkIdValidStr",
function(f, d) {
    var e = /^[a-zA-Z0-9\_\-\(\)]+$/;
    return this.optional(d) || (e.test(f))
},
"wrong id");












jQuery.validator.addMethod("isSecIDCard",
function(d, e, f) {
    if (!checkIfSecIdCard($(f).val())) {
        return true
    }
    return validateSecIdCard(d)
},
"wrong");













function checkIfSecIdCard(b) {
    if (b == "1") {
        return true
    }
    return false
}



function checkIfFirIdCard(b) {
    if (b == "2") {
        return true
    }
    return false
}



function checkCardForHKorTW(b) {
    if (b == "C" || b == "G") {
        return true
    }
    return false
}







jQuery.validator.addMethod("isFirIDCard",
function(d, e, f) {
    if (!checkIfFirIdCard($(f).val())) {
        return true
    }
    return validateFirIdCard(d)
},
"wrong");






jQuery.validator.addMethod("checkHkongMacao",
function(h, e, g) {
    if ($(g).val() == "C") {
        var f = /^[HMhm]{1}([0-9]{10}|[0-9]{8})$/;
        return this.optional(e) || (f.test(h))
    } else {
        return true
    }
},
"wrong format.");








jQuery.validator.addMethod("checkTaiw",
function(j, g, h) {
    if ($(h).val() == "G") {
        var i = /^[0-9]{8}$/;
        var f = /^[0-9]{10}$/;
        return this.optional(g) || (i.test(j)) || (f.test(j))
    } else {
        return true
    }
},
"wrong format.");








/*
jQuery.validator.addMethod("checkPassport",
function(i, f, h) {
    if ($(h).val() == "B") {
        var j = /^[a-zA-Z]*$/;
        if (j.test(i)) {
            return false
        }
        var g = /^[a-zA-Z0-9]{5,17}$/;
        return this.optional(f) || (g.test(i))
    } else {
        return true
    }
},
"wrong format.");

















jQuery.validator.addMethod("isMobile",
function(f, e) {
    var d = f.length;
    return this.optional(e) || (d == 11 && /^[0-9]+$/.test(f))
},
"wrong mobile phone ");












jQuery.validator.addMethod("isTelePhone",
function(d, e) {
    var f = /(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^[0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}#)/;
    return this.optional(e) || (f.test(d))
},
"wrong telePhone ");














jQuery.validator.addMethod("illegalChar",
function(j, f, h) {
    var i = true;
    for (var g = 0; g < j.length; g++) {
        if (j.charCodeAt(g) == 39 || j.charCodeAt(g) == 60 || j.charCodeAt(g) == 62 || j.charCodeAt(g) == 34 || j.charCodeAt(g) == 63) {
            i = false
        }
        if (!i) {
            break
        }
    }
    return this.optional(f) || i
},
"Illegal char wrong");











jQuery.validator.addMethod("isZipCode",
function(f, d) {
    var e = /^[0-9]{6}$/;
    return this.optional(d) || (e.test(f))
},
"wrong zipcode");
















jQuery.validator.addMethod("isEmail",
function(f, e) {
    var d = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return this.optional(e) || (d.test(trim(f)))
},
"wrong email");












function replaceChar(c) {
    var d = c.value.replace(/['"<> ?]/g, "");
    c.value = d
}





function checkNameChar1(b) {
    return /^[a-zA-Z0-9\u4E00-\u9FA5]+$/.test(b)
}





function trim(b) {
    return b.replace(/(^\s*)|(\s*$)/g, "")
}








function ltrim(b) {
    return b.replace(/(^\s*)/g, "")
}










function rtrim(b) {
    return b.replace(/(\s*$)/g, "")
}










jQuery.validator.addMethod("validateName",
function(c, d) {
    return this.optional(d) || /^[a-zA-Z\u4E00-\u9FA50-9\_]+$/.test(c)
},
"wrong username.");











jQuery.validator.addMethod("studentRequired",
function(d, e, f) {
    if ($(f).val() == "3") {
        return d && trim(d) != ""
    }
    return true
},
"wrong studentRequired.");











jQuery.validator.addMethod("studentStationRequired",
function(d, e, f) {
    if ($(f).val() == "3") {
        return d && trim(d) != "简拼/全拼/汉字" && trim(d) != ""
    }
    return true
},
"wrong studentStationRequired.");











jQuery.validator.addMethod("studentValidateName",
function(d, e, f) {
    if ($(f).val() == "3") {
        return this.optional(e) || /^[a-zA-Z\u4E00-\u9FA50-9\_]+$/.test(d)
    }
    return true
},
"wrong username.");










jQuery.validator.addMethod("checkStudentName",
function(d, e, f) {
    if ($(f).val() == "3") {
        if ((!d || trim(d) == "" || trim(d) == "简拼/全拼/汉字")) {
            return false
        }
    }
    return true
},
"wrong username.");












jQuery.validator.addMethod("isQuestionNull",
function(d, e, f) {
    if (jQuery.trim(d) != "") {
        if (jQuery.trim($(f[0]).val()) == "customQuestion" && jQuery.trim($(f[1]).val()) == "" || jQuery.trim($(f[0]).val()) == "") {
            return false
        }
    }
    return true
},
"you should input the question");






jQuery.validator.addMethod("isAnswerNull",
function(d, e, f) {
    if ((jQuery.trim($(f[0]).val()) == "customQuestion" && jQuery.trim($(f[1]).val()) != "") || (jQuery.trim($(f[0]).val()) != "")) {
        if (jQuery.trim(d) == "") {
            return false
        }
    }
    return true
},
"you should input the answer");












function checkSex(f, d, e) {
    if (!checkSexByCardId(f, d, e)) {
        if (!confirm("性别与身份证中的性别不符,是否继续?")) {
            return false
        } else {
            return true
        }
    } else {
        return true
    }
}




function checkSexByCardId(j, h, g) {
    function f(c, b) {
        var d = null;
        if (b.length == 15) {
            d = b.substring(14, 15)
        } else {
            if (b.length == 18) {
                d = b.substring(16, 17)
            } else {
                return true
            }
        }
        if (d == "x" || d == "X") {
            d = "10"
        }
        var e = parseInt(d);
        var a = e % 2;
        if (a === 0 && c === "F") {
            return true
        } else {
            if (a === 1 && c === "M") {
                return true
            } else {
                return false
            }
        }
    }
    var i = $(g).val();
    if (checkIfSecIdCard($(h).val()) && validateSecIdCard(i)) {
        if (i !== "") {
            return f(j, i)
        } else {
            return true
        }
    } else {
        if (checkIfFirIdCard($(h).val()) && validateFirIdCard(i)) {
            if (i !== "") {
                return f(j, i)
            } else {
                return true
            }
        } else {
            return true
        }
    }
}












function checkBirdDateByCardId(j, h, f) {
    var g = null;
    var i = $(f).val();
    if (checkIfSecIdCard($(h).val()) && i !== "" && validateSecIdCard(i)) {
        g = i.substring(6, 14)
    } else {
        if (checkIfFirIdCard($(h).val()) && i !== "" && validateFirIdCard(i)) {
            if (i.length == 15) {
                g = "19" + i.substring(6, 12)
            } else {
                if (i.length == 18) {
                    g = i.substring(6, 14)
                }
            }
        } else {
            return true
        }
    }
    if (j !== "") {
        j = j.replace(/-/g, "");
        if (j != g) {
            return false
        } else {
            return true
        }
    } else {
        return true
    }
}









function checkBirdate(f, d, e) {
    if (!checkBirdDateByCardId(f, d, e)) {
        if (!confirm("出生日期与身份证中的出生日期不符,是否继续?")) {
            return false
        } else {
            return true
        }
    } else {
        return true
    }
}







jQuery.validator.addMethod("checkPwdValidate",
function(c, d) {
    return this.optional(d) || /(?![a-z]+$|[0-9]+$|_+$)^[a-zA-Z0-9_]{6,}$/.test(c)
},
"contain writespace");










jQuery.validator.addMethod("checkConfirmPassWard",
function(d, e, f) {
    if ($(f).val() != null) {
        return $(f).val() == d
    }
    return true
},
"contain writespace");









jQuery.validator.addMethod("IVR_passwd_format",
function(d, e) {
    var f = /^[0-9]{6}$/;
    return this.optional(e) || f.test(d)
},
"验证码错误!.");









jQuery.validator.addMethod("checkStation",
function(c, d) {
    if ((!c || trim(c) == "" || trim(c) == "简拼/全拼/汉字" || trim(c) == "简拼/全拼/汉字或↑↓")) {
        return false
    }
    return true
},
"wrong username.");









jQuery.validator.addMethod("checkAnsyUserName",
function(j, l, i) {
    var g = i[0];
    var k = $("#" + i[1]).val();
    var h = true;
    $.ajax({
        url: g + "?user_name=" + j,
        type: "get",
        async: false,
        success: function(b, a) {
            if (b.data == true) {
                h = false
            } else {
                h = true
            }
        },
        error: function(c, a, b) {
            h = false
        }
    });
    return h
},
"wrong cardNo");












function checkPwdRank(h, g, i) {
    var f = $(h);
    var j = f.val();
    if (j.length <= 6 || new RegExp("^[a-zA-Z]{6,}$").test(j) || new RegExp("^[0-9]{6,}$").test(j) || new RegExp("^[_]{6,}$").test(j)) {
        $("#" + g).attr("title", "危险");
        $("#" + i).html("危险");
        $("#" + g).removeClass("rank-a");
        $("#" + g).removeClass("rank-b");
        $("#" + g).removeClass("rank-c");
        $("#" + g).addClass("rank-a")
    } else {
        if (j.length > 6 && new RegExp("[a-zA-Z]").test(j) && new RegExp("[0-9]").test(j) && new RegExp("[_]").test(j)) {
            $("#" + g).attr("title", "安全");
            $("#" + i).html("安全");
            $("#" + g).removeClass("rank-a");
            $("#" + g).removeClass("rank-b");
            $("#" + g).removeClass("rank-c");
            $("#" + g).addClass("rank-c")
        } else {
            $("#" + g).attr("title", "一般");
            $("#" + i).html("一般");
            $("#" + g).removeClass("rank-a");
            $("#" + g).removeClass("rank-b");
            $("#" + g).removeClass("rank-c");
            $("#" + g).addClass("rank-b")
        }
    }
}








Array.prototype.unique = function() {
    var d = {},
    e = this.length;
    for (var f = 0; f < e; f++) {
        if (typeof d[this[f]] == "undefined") {
            d[this[f]] = 1
        }
    }
    this.length = 0;
    e = 0;
    for (var f in d) {
        this[e++] = f
    }
    return this
};










function checkSearchPwdRank(k, p, l) {
    var n = $(k);
    var m = n.val();
    if (m.length < 6) {
        $("#" + p).attr("title", "危险");
        $("#" + l).html("危险");
        $("#" + p).removeClass("rank-a");
        $("#" + p).removeClass("rank-b");
        $("#" + p).removeClass("rank-c");
        $("#" + p).addClass("rank-a")
    } else {
        var j = [];
        for (var i = 0; i < 6; i++) {
            j.push(m.charAt(i))
        }
        j = j.unique();
        var o = j.length;
        if (o == 1) {
            $("#" + p).attr("title", "危险");
            $("#" + l).html("危险");
            $("#" + p).removeClass("rank-a");
            $("#" + p).removeClass("rank-b");
            $("#" + p).removeClass("rank-c");
            $("#" + p).addClass("rank-a")
        } else {
            if (o > 1 && o < 5) {
                $("#" + p).attr("title", "一般");
                $("#" + l).html("一般");
                $("#" + p).removeClass("rank-a");
                $("#" + p).removeClass("rank-b");
                $("#" + p).removeClass("rank-c");
                $("#" + p).addClass("rank-b")
            } else {
                $("#" + p).attr("title", "安全");
                $("#" + l).html("安全");
                $("#" + p).removeClass("rank-a");
                $("#" + p).removeClass("rank-b");
                $("#" + p).removeClass("rank-c");
                $("#" + p).addClass("rank-c")
            }
        }
    }
}; 








(function() {
    $(document).ready(function() {
        $.sidebar_init(7);
        if ("3" != isStudent) {
            $("#_stu_infor").hide()
        }
        $("#passengerType").on("change",
        function() {
            if ($(this).val() == "3") {
                $("#_stu_infor").show(800)
            } else {
                $("#_stu_infor").hide(800)
            }
        });
        $("#bornDate").focus(function() {
            WdatePicker({
                doubleCalendar: false,
                isShowClear: false,
                readOnly: true,
                qsEnabled: false,
                onpicked: function() {
                    $("#bornDate").blur()
                }
            })
        });
        $._initForm();
        $._show_id_no();
        $._show_mobile_no()
    });

    var a = new dhtmlXWindows();
    a.enableAutoViewport(true);
    a.setSkin("dhx_terrace");
    a.setImagePath(ctx + "resources/js/rich/windows/imgs/");


    jQuery.extend({
        cancelAdd: function() {
            otsRedirect("post", ctx + "passengers/init")
        },

        _toAdd: function() {
            $("#_addForm").submit()
        },

        _show_id_no: function() {
            $("#cardCode").on("focus",
            function() {
                var d = $("#cardCode").val();
                if (d != "") {
                    var c = "";
                    var b = d.length;
                    if (d.length <= 3) {
                        c = d
                    } else {
                        if (b <= 6) {
                            c = d.substring(0, 3) + " " + d.substring(3, b)
                        } else {
                            if (b <= 10) {
                                c = d.substring(0, 3) + " " + d.substring(3, 6) + "  " + d.substring(6, b)
                            } else {
                                if (b <= 14) {
                                    c = d.substring(0, 3) + " " + d.substring(3, 6) + "  " + d.substring(6, 10) + " " + d.substring(10, b)
                                } else {
                                    c = d.substring(0, 3) + " " + d.substring(3, 6) + "  " + d.substring(6, 10) + " " + d.substring(10, 14) + " " + d.substring(14, b)
                                }
                            }
                        }
                    }
                    $("#passenger_id_no_div").html(c);
                    $("#passenger_id_no_div").css("display", "block")
                } else {
                    $("#passenger_id_no_div").html("");
                    $("#passenger_id_no_div").css("display", "none")
                }
            });
            $("#cardCode").on("keyup",
            function() {
                $("#passenger_id_no_div").css("display", "block");
                var d = $("#cardCode").val();
                var c = "";
                var b = d.length;
                if (d.length <= 3) {
                    c = d
                } else {
                    if (b <= 6) {
                        c = d.substring(0, 3) + " " + d.substring(3, b)
                    } else {
                        if (b <= 10) {
                            c = d.substring(0, 3) + " " + d.substring(3, 6) + "  " + d.substring(6, b)
                        } else {
                            if (b <= 14) {
                                c = d.substring(0, 3) + " " + d.substring(3, 6) + "  " + d.substring(6, 10) + " " + d.substring(10, b)
                            } else {
                                c = d.substring(0, 3) + " " + d.substring(3, 6) + "  " + d.substring(6, 10) + " " + d.substring(10, 14) + " " + d.substring(14, b)
                            }
                        }
                    }
                }
                $("#passenger_id_no_div").html(c)
            });
            $("#cardCode").on("blur",
            function() {
                $("#passenger_id_no_div").html("");
                $("#passenger_id_no_div").css("display", "none")
            })
        },
        _show_mobile_no: function() {
            $("#mobileNo").on("focus",
            function() {
                var d = $("#mobileNo").val();
                if (d != "") {
                    var c = "";
                    var b = d.length;
                    if (d.length <= 3) {
                        c = d
                    } else {
                        if (b <= 7) {
                            c = d.substring(0, 3) + " " + d.substring(3, b)
                        } else {
                            c = d.substring(0, 3) + " " + d.substring(3, 7) + "  " + d.substring(7, b)
                        }
                    }
                    $("#mobile_no_div").html(c);
                    $("#mobile_no_div").css("display", "block")
                } else {
                    $("#mobile_no_div").html("");
                    $("#mobile_no_div").css("display", "none")
                }
            });
            $("#mobileNo").on("keyup",
            function() {
                $("#mobile_no_div").css("display", "block");
                var d = $("#mobileNo").val();
                var c = "";
                var b = d.length;
                if (d.length <= 3) {
                    c = d
                } else {
                    if (b <= 7) {
                        c = d.substring(0, 3) + " " + d.substring(3, b)
                    } else {
                        c = d.substring(0, 3) + " " + d.substring(3, 7) + "  " + d.substring(7, b)
                    }
                }
                $("#mobile_no_div").html(c)
            });
            $("#mobileNo").on("blur",
            function() {
                $("#mobile_no_div").html("");
                $("#mobile_no_div").css("display", "none")
            })
        },
        _initForm: function() {
            $("#_addForm").validate({
                rules: {
                    passenger_name: {
                        required: true,
                        byteRangeLength: [3, 20],
                        checkNameCharBlank: "cardType@cardCode"
                    },
                    sex_code: {
                        required: true
                    },
                    born_date: {
                        checkBorth: "checkBorth"
                    },
                    passenger_id_no: {
                        required: true,
                        checkIdValidStr: true,
                        isSecIDCard: "#cardType",
                        isFirIDCard: "#cardType",
                        checkHkongMacao: "#cardType",
                        checkTaiw: "#cardType",
                        checkPassport: "#cardType"
                    },
                    email: {
                        isEmail: true
                    },
                    mobile_no: {
                        isMobile: true
                    },
                    phone_no: {
                        illegalChar: true
                    },
                    address: {
                        illegalChar: true
                    },
                    postalcode: {
                        isZipCode: true
                    },
                    "studentInfoDTO.school_name": {
                        checkStudentName: "#passengerType"
                    },
                    "studentInfoDTO.department": {
                        studentValidateName: "#passengerType"
                    },
                    "studentInfoDTO.school_class": {
                        studentValidateName: "#passengerType"
                    },
                    "studentInfoDTO.student_no": {
                        studentRequired: "#passengerType",
                        studentValidateName: "#passengerType"
                    },
                    "studentInfoDTO.preference_card_no": {
                        studentValidateName: "#passengerType"
                    },
                    "studentInfoDTO.enter_year": {
                        studentRequired: "#passengerType"
                    }
                },
                messages: {
                    passenger_name: {
                        required: "请输入您的姓名!",
                        byteRangeLength: jQuery.format("允许输入的字符串在{0}-{1}个字符之间!"),
                        checkNameCharBlank: "姓名只能包含中文或者英文!"
                    },
                    sex_code: {
                        required: "请选择性别"
                    },
                    born_date: {
                        checkBorth: "生日格式不合法"
                    },
                    passenger_id_no: {
                        required: "请输入证件号码!",
                        isSecIDCard: jQuery.format("请正确输入18位的身份证号!"),
                        isFirIDCard: jQuery.format("请正确输入15或者18位的身份证号!"),
                        checkIdValidStr: "输入的证件编号中包含中文信息或特殊字符!",
                        checkHkongMacao: "请输入有效的港澳居民通行证号码!",
                        checkTaiw: "请输入有效的台湾居民通行证号码!",
                        checkPassport: "请输入有效的护照号码!"
                    },
                    email: {
                        isEmail: "请输入有效的电子邮件地址!"
                    },
                    mobile_no: {
                        isMobile: "您输入的手机号码不是有效的格式!"
                    },
                    phone_no: {
                        illegalChar: "您输入的固定电话中含有非法字符!"
                    },
                    address: {
                        illegalChar: "您输入的地址中含有非法字符!"
                    },
                    postalcode: {
                        isZipCode: "您输入的邮编不是有效的格式!"
                    },
                    "studentInfoDTO.school_name": {
                        checkStudentName: "请选择学校名称"
                    },
                    "studentInfoDTO.department": {
                        studentValidateName: "院系只能包含中文、英文、数字!"
                    },
                    "studentInfoDTO.school_class": {
                        studentValidateName: "班级只能包含中文、英文、数字!"
                    },
                    "studentInfoDTO.student_no": {
                        studentRequired: "请输入学号",
                        studentValidateName: "学号只能包含中文、英文、数字!"
                    },
                    "studentInfoDTO.preference_card_no": {
                        studentValidateName: "优惠卡号只能包含中文、英文、数字!"
                    },
                    "studentInfoDTO.enter_year": {
                        studentRequired: "请输入入学年份 "
                    }
                },
                errorPlacement: function(b, c) {
                    if (c.attr("name") == "passenger_name") {
                        b.insertAfter(c.parent().parent());
                        c.parent().parent().next().css("margin-left", c.parent().position().left)
                    } else {
                        if (c.attr("name") == "sex_code") {
                            b.insertAfter(c.parent().parent());
                            c.parent().parent().next().css("margin-left", "130px")
                        } else {
                            b.insertAfter(c.parent());
                            c.parent().next().css("margin-left", "2px").css("line-height", "30px")
                        }
                    }
                },
                submitHandler: function(e) {
                    var d = null;
                    $("input[name=sex_code]").each(function() {
                        if (this.checked) {
                            d = this.value
                        }
                    });
                    if (checkSex(d, "#cardType", "#cardCode") && checkBirdate($("#bornDate").val(), "#cardType", "#cardCode")) {
                        var c = $("#preference_from_station_name").val();
                        if (c = "简码/汉字") {
                            c = ""
                        }
                        var b = $("#preference_to_station_name").val();
                        if (b = "简码/汉字") {
                            b = ""
                        }
                        $.ajax({
                            url: ctx + "passengers/add",
                            type: "post",
                            data: {
                                passenger_name: $("#name").val(),
                                old_passenger_name: $("#oldName").val(),
                                sex_code: d,
                                _birthDate: $("#bornDate").val(),
                                country_code: $("#nation").val(),
                                passenger_id_type_code: $("#cardType").val(),
                                old_passenger_id_type_code: $("#oldCardType").val(),
                                passenger_id_no: $("#cardCode").val(),
                                old_passenger_id_no: $("#oldCardCode").val(),
                                mobile_no: $("#mobileNo").val(),
                                phone_no: $("#phoneNo").val(),
                                email: $("#email").val(),
                                address: $("#address").val(),
                                postalcode: $("#zipCode").val(),
                                passenger_type: $("#passengerType").val(),
                                "studentInfoDTO.province_code": $("#province_code").val(),
                                "studentInfoDTO.school_code": $("#schoolCode").val(),
                                "studentInfoDTO.school_name": $("#schoolNameText").val(),
                                "studentInfoDTO.department": $("#department").val(),
                                "studentInfoDTO.school_class": $("#school_class").val(),
                                "studentInfoDTO.student_no": $("#student_no").val(),
                                "studentInfoDTO.school_system": $("#school_system").val(),
                                "studentInfoDTO.enter_year": $("#enter_year").val(),
                                "studentInfoDTO.preference_card_no": $("#preference_card_no").val(),
                                "studentInfoDTO.preference_from_station_name": c,
                                "studentInfoDTO.preference_from_station_code": $("#preferenceFromStationCode").val(),
                                "studentInfoDTO.preference_to_station_name": b,
                                "studentInfoDTO.preference_to_station_code": $("#preferenceToStationCode").val()
                            },
                            success: function(f) {
                                if (f.status) {
                                    if (f.data.flag) {
                                        dhtmlx.alert({
                                            title: "添加常用联系人",
                                            ok: "确定",
                                            text: "添加成功!",
                                            type: "dhtmlx_popup_title",
                                            callback: function() {
                                                otsRedirect("post", ctx + "passengers/init")
                                            }
                                        })
                                    } else {
                                        dhtmlx.alert({
                                            title: "添加常用联系人",
                                            ok: "确定",
                                            text: f.data.message,
                                            type: "alert-error"
                                        })
                                    }
                                }
                            }
                        })
                    }
                }
            })
        }
    })
})();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值