Guys,

I'm redoing some of my old functions. Right now i have a form
validation function (PHP and SmartyValidate) which echoes the
following line of code after an invalid form field:
<div class="formError">... message ...</div>

I also have a formReset function, which basicly sets the focus to the
first visible and enabled form field. The code reads like this:
jQuery(":input:visible:enabled:first", this).focus();

where "this" is the form off course.

Here's the challenge.
Instead of simply setting the focus to the first visible and inabled
form element, i want the focus to be on the element which has
formError after it. One can assume that any form error matches both an
enabled and visible field.

Given this query:
jQuery('.formError:first', this);

I basically have this question:
How can i find the first input element, before an object? E.g. is
there a reverse search in jQuery?
And if so, can it be combined into 1 query?

-- Gilles

Reply via email to