简体   繁体   中英

about validate.js use function

            "data[ResearchCase][sender_mail]": {
            required: function() { 
                return $("#customer_info").val() =="2";
            },
            email: function() { 
                return $("#customer_info").val() =="2";
            }
        }
        messages: {
         "data[ResearchCase][sender_mail]": {
            required: "must input mail",
            email:"not right email"
         }
        }

when customer_info = 1. the required validate is not work,but the email validate always work。 i try wirte like

email:function(){retrun false}
or
email:function(){retrun 0}

also not work i also try to delete required validate, but email also work. where i am wrong?

hoho, i know why in the validate.js the email check is not have parameters the old code

        email: function(value, element) {
        return this.optional(element) || /^(((....)))\.?$/i.test(value);
    },

the new code

        email: function(value, element, param) {
        if (!param) {
            return true;
        }
        return this.optional(element) || /^(((....)))\.?$/i.test(value);
    },

when customer_info = 1 ,the eamil validate is not work. but i have other question,when i wirte eamil:false, the email validate is not work,so what diffrent for

email:function(){return false}

to

email:false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM