开发者

Jquery Validation Central Message Many Errors

I have a form that is being valdated with the Jquery Validation Plugin. I have managed to get a centeral message "Please Recheck the form", and to have the input focus on the first error. To get this, I had to override the default message of each of the errors. I was wondering if anyone could help me figure out how I can have it display the error message associated with the first error input instead of a general error message. Here is the code:

$("#Help-A-N开发者_如何学Coobie-Form" ).validate({

 invalidHandler: function(form, validator) {      
     $(this).find(":input.error:first").focus();
     var message = 'Please Recheck The Form' ;
    $("#Help-A-Noobie-Form #Message p").addClass('red').html(message);        
   },

showErrors: function(errorMap, errorList) {

this.defaultShowErrors(); },

rules: { required:true, email: {email:true}, phone: {digits:true}

},

messages: { email: "", phone: "", lastname: "", firstname: "", required:"" } })


$("#Help-A-Noobie-Form" ).validate({
    onfocusout: false,
    onkeyup: false,
    showErrors: function(errorMap, errorList) {
        if (errorList.length > 0) {
            jQuery('.errors').html('<div id="error" class="erreur">' + errorList[0].message + '</div>');
        }
    }, 
    rules: {
        email: { email:true },
        phone: { digits:true }
    },  

    messages: { 
        email: { email: 'please enter a valid email' },
        phone: { digits: 'please enter a valid phone' }
    }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜