1
lxl
2022-09-16 cb746cca26fa024018d7ce772ba6a96557ea768b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var form2 = null;
function cheackForm(formId) {
    form2 = jQuery("#" + formId);
    var error2 = $('.alert-error', form2);
    var success2 = $('.alert-success', form2);
    form2.validate({
        errorElement: 'span', //default input error message container
        errorClass: 'help-inline', // default input error message class
        focusInvalid: false, // do not focus the last invalid input
        ignore: "",
        errorPlacement: function (label, element) {
            // alter: Xxx
            // time: 20181206
            // msg: 新增自定义验证提示消息,去除错误提示图标,新增错误提示文本展示
 
            //单个验证错误提示
            var diyMsg = element[0].getAttribute("diyMsg");
            var errorMsg = label.html();
            if(diyMsg != null && diyMsg != "") {
                errorMsg = diyMsg;
            }
            //jQuery(element).parent('.input-icon').find('span.input-warning').attr("title", errorMsg);
            jQuery(element).parent('.input-icon').find('span.input-warning').html(errorMsg);
            jQuery(element).parent('.input-icon').find("span.input-warning").css("display", "");
            // jQuery(element).parent('.input-icon').find('span.input-warning').addClass("fa fa-exclamation-triangle");
        },
 
        invalidHandler: function (event, validator) { //display error alert on form submit
            success2.hide();
            error2.show();
            // App.scrollTo(error2, -200);
        },
        highlight: function (element) { // highlight error inputs
            // alter: Xxx
            // time: 20181206
            // msg: 去除错误提示图标
            element.style.borderColor = "#b94a48";
            // jQuery(element).parent('.input-icon').find("i").removeClass("fa-ok").addClass("fa-exclamation-sign");
            // jQuery(element).parent('.input-icon').find("i").css("display", "block");
        },
 
        unhighlight: function (element) { // revert the change done by highlight
            // alter: Xxx
            // time: 20181206
            // msg: 去除错误提示图标
            element.style.borderColor = "";
            jQuery(element).closest('.control-group').removeClass('error'); // set error class to the control group
            // jQuery(element).parent('.input-icon').find("span.input-warning").removeClass("fa-exclamation-sign").addClass("fa-ok");
            jQuery(element).parent('.input-icon').find("span.input-warning").css("display", "none");
            // jQuery(element).parent('.input-icon').find("i").removeClass("fa-exclamation-sign").addClass("fa-ok");
            // jQuery(element).parent('.input-icon').find("i").css("display", "none");
        },
        success: function (label) {
            try {
                label
                    .addClass('valid').addClass('help-inline ok') // mark the current input as valid and display OK icon
                    .closest('.control-group').removeClass('error').addClass('success'); // set success class to the control group
                label.remove();
            } catch (e) {
 
            }
        },
        submitHandler: function (form) {
            success2.show();
            error2.hide();
        }
    });
}