While it is not exactly the best way to do it (it uses undocumented settings), I have found a solution, but still have one issue - the showErrors function still runs when there are no errors (i.e. the errors parameter is an empty object).
var validator = $("form").validate( { onblur: function(){}, onkeyup: function(el) { if(validator.check(el)) $(el).removeClass(validator.settings.errorClass); else $(el).addClass(validator.settings.errorClass); }, showErrors: function(errors) { alert("should only fire on submit"); } }); On Jun 28, 11:44 am, Sam Collett <[EMAIL PROTECTED]> wrote: > The validation doesn't fire on element blur before you submit the form > (only after), perhaps it may be a bug? > > What I want to do is show a message when the form is submitted, not > when an element loses focus (but also want the error class to be added > to an element when it is not valid). > > What may be a good solution (but would probably mean a change to the > plugin by Jörn) is if there was a way to know what element fired the > validation and what event (blur, submit etc) was the trigger. > > On Jun 28, 11:20 am, "Rob Desbois" <[EMAIL PROTECTED]> wrote: > > > Sam, > > > On the API documentation page have a look at the examples for .validate() > > -http://jquery.bassistance.de/api-browser/plugins.html#validateMap > > > There is a parameter called 'event' which seems to control when each input > > is validated, its use is shown a couple of times. > > This isn't documented but shouldn't be too hard to work out its semantics - > > I'd love to help further but haven't used the validate() plugin myself. > > > HTH, > > --rob > > > On 6/28/07, Sam Collett <[EMAIL PROTECTED]> wrote: > > > > Is it possible to only run validation when the form is submitted? I am > > > using version 1.1 of the validation plugin (http://bassistance.de/ > > > jquery-plugins/jquery-plugin-validation/) > > > > I want to do something only when the form is submitted, so tried this > > > basic code: > > > > $("form").validate( > > > { > > > showErrors: function(errors) > > > { > > > alert("should only fire on submit"); > > > } > > > }) > > > > The alert shows when I try to submit the form, and also when I click > > > the page after dismissing the alert. > > > > Test page:http://www.texotela.co.uk/validation.php > > > -- > > Rob Desbois > > Eml: [EMAIL PROTECTED] > > Tel: 01452 760631 > > Mob: 07946 705987 > > "There's a whale there's a whale there's a whale fish" he cried, and the > > whale was in full view. > > ...Then ooh welcome. Ahhh. Ooh mug welcome.