Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Validation on Success

I have this registration form which is then validated using "bassistance's" validate.js:

$('#pForm').validate({ 
        rules: { 
            fname: "required",// simple rule, converted to {required:true} 
        lname: "required",
        accType: "required",
        country: "required",
            email: {// compound rule 
                required: true, 
                email: true 
                },
        city: "required"
        },
        success: function(){
            $('#pForm').hide('slow');
            $('#accForm').show('slow');
                        }
});//form validate

Now, validation is working fine, except the success tag (which I've added). So, although it says that fields are required, it goes ahead and reads the code under "success" as soon as I change one field. Any ideas how I can get around this one? And is there an "onFailure" type of tag is jQuery?

like image 728
uran Avatar asked Feb 16 '26 22:02

uran


1 Answers

Seems your success: callback is improperly defined, it must have one string argument as described in the documentation:

success String, Callback
If specified, the error label is displayed to show a valid element. If a String is given, its added as a class to the label. If a Function is given, its called with the label (as a jQuery object) as its only argument. That can be used to add a text like "ok!".

Does it work when you provide a simple class-name string instead of the callback?

like image 187
r00fus Avatar answered Feb 18 '26 11:02

r00fus