views:

353

answers:

1

Hey guys thanks in advance for all your help! 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? Oh... and is there an "onFailure" type of tag is jQuery?

A: 

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?

r00fus
well.. I just tried it by giving it a string "OK" and it worked... but I am not sure what you mean by "class-name string..Is there any way that I can call some kind of a function in there so i can proceed to the next form?
uran
When you supplied the string "OK", it applies that class "OK" to any succeeding elements. Try making your callback defined assuccess: function(string) {...} and see if that works.
r00fus