开发者

Jquery validator - common message for all the errors

开发者 https://www.devze.com 2023-03-10 19:16 出处:网络
I am using the following validation rules for my form. I need to display one common error message for all the validations. I have grouped the controls but can not pass the message.

I am using the following validation rules for my form. I need to display one common error message for all the validations. I have grouped the controls but can not pass the message.

$(function() {

jQuery.validator.addMethod("lettersonly", function(value, element) {
r开发者_JS百科eturn this.optional(element) || /^[a-z]+$/i.test(value);
}, "Letters only please");

$(".form").validate({

errorLabelContainer: "#errorMessages",
groups: {
    username: "name email lName zip"
},
rules: {
    name:{
        required: true,
        lettersonly: true
    },
    email: {
        required: true,
        email: true
    },
    lName: "required",
    zip: "required"
},      
messages: {
    username:"Sorry friend, your vote was not processed because you forgot to enter the required information. Enter it now."
}
});
});


function(){
    bValid = bValid && Function1toValidate($('#txtTitle'));
    bValid = bValid && Function2toValidate($('#txtEmail'));

    if (bValid)
    {
        proceed with the procedure
    }
    else
    {
        your error message
    }
}

//those validate functions code it here
Function1toValidate()
{}
Function2toValidate()
{}
0

精彩评论

暂无评论...
验证码 换一张
取 消