I can't reproduce that. Seems to work fine for me.

Jörn

On Tue, Sep 15, 2009 at 11:40 PM, Geoffrey <geoffreydhug...@gmail.com> wrote:
>
> Hmmm...I tried this but I discovered on the first submit that it
> doesn't focus the first invalid field but it will if I hit return to
> submit again.
>
> Also, when hitting submit on a field that's not checked for validity,
> the form will submit successfully this second time as well despite
> still having invalid fields.
>
> You can test it out using my sample form from the OP.
>
>
> On Sep 16, 8:37 am, Geoffrey <geoffreydhug...@gmail.com> wrote:
>> Damn.  I always forget about :first.
>>
>> Thanks.
>>
>> On Sep 16, 8:34 am, Jörn Zaefferer <joern.zaeffe...@googlemail.com>
>> wrote:
>>
>>
>>
>> > Something like this?
>>
>> > $("form").validate({
>> >   focusInvalid: false,
>> >   invalidHandler: function() {
>> >     $(this).find(":input.error:first").focus();
>> >   }
>>
>> > });
>>
>> > Jörn
>>
>> > On Tue, Sep 15, 2009 at 10:24 PM, Geoffrey <geoffreydhug...@gmail.com> 
>> > wrote:
>>
>> > > I guess I'm going to have too.  I just need to work out how to return
>> > > the first invalid field so I can set the focus.
>>
>> > > On Sep 16, 8:16 am, Jörn Zaefferer <joern.zaeffe...@googlemail.com>
>> > > wrote:
>> > >> Well, you can set focusInvalid: false and implement invalidHandler to
>> > >> focus the first field. That should do the trick.
>>
>> > >> Jörn
>>
>> > >> On Tue, Sep 15, 2009 at 10:01 PM, Geoffrey <geoffreydhug...@gmail.com> 
>> > >> wrote:
>>
>> > >> > And what if you enter an invalid character in an input at the bottom
>> > >> > of the field? For example entering a letter in the Conference Dinner
>> > >> > input of my sample form.
>>
>> > >> > A user is going to miss the error message at the top of the form along
>> > >> > with other input errors if there's an error in the last inputs of my
>> > >> > example form and is going to have submit multiple times before they
>> > >> > may even be aware of other errors.
>>
>> > >> > I'd expected jumping to the first invalid input to be standard
>> > >> > behaviour.  My fault there I guess.
>>
>> > >> > On Sep 15, 10:08 pm, Jörn Zaefferer <joern.zaeffe...@googlemail.com>
>> > >> > wrote:
>> > >> >> Whats wrong with keeping the focus on the active field, if its 
>> > >> >> invalid?
>>
>> > >> >> If you enter something into the, say, third field, hit enter to
>> > >> >> submit, then it turns out both that field and another before that are
>> > >> >> invalid, why move the focus to a different field?
>>
>> > >> >> Jörn
>>
>> > >> >> On Tue, Sep 8, 2009 at 4:47 AM, Geoffrey <geoffreydhug...@gmail.com> 
>> > >> >> wrote:
>>
>> > >> >> > I've been building up my validation using the jquery validation 
>> > >> >> > plugin
>> > >> >> > but I can't work out how to get a failed validation to default the
>> > >> >> > focus to the first invalid input rather than to the last selected
>> > >> >> > input.
>>
>> > >> >> > If there is no input field selected, when I submit then a failed
>> > >> >> > validation will focus the cursor on the first field but if the 
>> > >> >> > cursor
>> > >> >> > was left in a field and submitted then the focus stays there (if 
>> > >> >> > it's
>> > >> >> > invalid) rather than jump to the first invalid input.  From what 
>> > >> >> > I've
>> > >> >> > read and seen, this is the expected behaviour but not what I want.
>>
>> > >> >> > Is there a way I can get the first invalid field and set the focus 
>> > >> >> > to
>> > >> >> > that?
>>
>> > >> >> > A demo of what I have built up so far can be seen at
>> > >> >> >https://webdev2.otago.ac.nz/oihrn2009/
>>
>> > >> >> > All my jquery validation can be found in
>> > >> >> >https://webdev2.otago.ac.nz/oihrn2009/javascript/document.ready.all.js

Reply via email to