Jquery验证器 - 所有错误的常见消息

时间:2011-06-07 12:48:11

标签: jquery jquery-validate

我正在为表单使用以下验证规则。我需要为所有验证显示一条常见错误消息。我已将控件分组但无法传递消息。

$(function() {

jQuery.validator.addMethod("lettersonly", function(value, element) {
return 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."
}
});
});

1 个答案:

答案 0 :(得分:0)

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()
{}