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?
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With