Suggestion for Validate plugin

Suggestion for Validate plugin

JQuery validate plugin have invalidHandler init function which get triggered if something is invalid however it does not have anything for validHandler where you you want trigger something immediately if validation succeeds (i.e like hide something - which was in my case). So, here is my suggestion with code modification.
  1. numberOfInvalids: function()
    {
          /*
          * Modification starts here...
          * Nirmal R Poudyal aka nicholasnet
          */
          if(this.objectLength(this.invalid) === 0)
          {
                if(this.validTrack === false)
                {
                      if(this.settings.validHandler)
                      {
                            this.settings.validHandler();
                      }
                      this.validTrack = true;
                }














  2.             else
  3.             {
  4.                    this.validTrack = false;
                }
           //End of modification
           return this.objectLength(this.invalid);
     },





and in init
  1. init: function()

  2. {
          this.validTrack = false;
  3. ........

Now you can do something like
  1. $("#userEntry").validate
    ({
          invalidHandler: function()
          {
                $('#errorContainer').css({'display':'block'});
          },
          validHandler: function()
          {
                $('#errorContainer').css({'display':'none'});
          },
          errorLabelContainer: $("#errorContent"),
          wrapper: 'p',
          rules:
          {
                firstname: "required",
                lastname: "required"
          },
          messages:
          {
                firstname: "Please enter your firstname",
                lastname: "Please enter your lastname"
          },
          submitHandler: function(form)
          {
                $('#errorContainer').css({'display':'none'});
          }
    });



























I hope this will help somebody. If there is better way to achieve this then please share.