Right, after further investigation I believe that the problem is
deeper than simply a bug with validate (I don't think there is one;
it's just not designed to do what I'm attempting). So I figured I'd
write up some more of my thoughts about what I'd like to do.
Essentially, for a given form, I want to be able to fire an event
onchange of all input elements which tests the validity only of those
inputs which have so far been touched by the user.

So assuming the following scenario:

<form name="signup">
<input type="text" name="displayname" />
<input type="text" name="emailaddress" />
<input type="password" name="signuppassword" />
<input type="password" name="signuppasswordconfirm" />
<input type="submit" />
</form>

Let's say that all of these fields are required, and the final two are
linked passwords (they have to be the same). Let's also say that I
want to change the background colour of the form element according to
the form's state (red for problems, green for everything being good,
and grey if the user hasn't finished entering into the fields). Now if
the user types in their display name and tabs to the next field, the
form as a whole - if it were submitted right then - is invalid, as
they've not provided any of the other required fields. However for the
purposes of flagging the form's colour, I'd not want to immediately
change the colour to red, as the user hasn't even had chance to
provide those fields yet. However, if the user types their display
name and then enters a malformed email address (assuming I'm
validating based on email address format) and tabs to the first
password field, I would want to flag the form with the colour change,
as even though they've not completed the form, there is a definite
error on it.

>From what I can tell, there is no distinction made within the
validation method given above between form fields which have had user
focus and had input entered into and form fields which are 'virgin'. I
must admit, I'm uncertain as to the purpose of using elements[i] as
the ending condition of the loop, but it appears that it will loop
over every input in the form.

So, what can you recommend? What might be a way of accomplishing this
within what exists already, or should I try to create something
independent to handle this sort of scenario?

Reply via email to