Details about the default behaviour are here:
http://docs.jquery.com/Plugins/Validation/Reference#Validation_event

You can make the validation more aggresive with some custom event handling:

$("input[name=q4]").click(function() {
  $(this).valid();
});

Jörn

PS: You really shouldn't use a single id more then once (id="q4")

On Mon, Oct 13, 2008 at 5:34 PM, w1ntermut3 <[EMAIL PROTECTED]> wrote:
>
> Using the Validation plugin (http://docs.jquery.com/Plugins/
> Validation/)
>
> I've got checkboxes like this:
>
> <input type="checkbox" name="q4" id="q4" value="1" />
> <input type="checkbox" name="q4" id="q4" value="2" />
> <input type="checkbox" name="q4" id="q4" value="3" />
> <input type="checkbox" name="q4" id="q4" value="4" />
> <input type="checkbox" name="q4" id="q4" value="5" />
>
> and the following code making sure that only 3 can be chosen:
>
> $(document).ready(function() {
>        $('#fQuestionnaire1').validate({
>                rules: {
>                        q4: {
>                                required: true,
>                                maxlength: 3
>                        }
>                }
>        });
> });
>
> This sort of works fine - when I click the form's Submit button, the
> error message is displayed if more than three are selected. And from
> then on,  the error message is toggled on and off by my ticking the
> required number of boxes. But - and here's my question - I want that
> behaviour BEFORE I've hit "Submit". As soon as I click that 4th
> checkbox, I want the error message to appear. Currently it's happy to
> let me select 4 items and then gives me the message when I hit
> "Submit".
>
> I notice that the docs for the validate() "onfocusout" option - which
> defaults to true - says "Validate elements (except checkboxes/radio
> buttons) on blur." Why are they excluded? It's clearly possible to do,
> because it does validate onblur AFTER the submit button has fired
> once. Is this work-aroundable? Am I missing something important?
>
> Thanks :)
>
>
>

Reply via email to