C
Christoph
I'm trying to validate some HTML form elements when the
user tabs out of each element. However, I'm having some
problems.
It appears that the order of events is onChange followed
some time afterwards by onBlur. I believe this to be the
case because in my onChange script, if the validation fails,
I force focus back to the field element. However, the focus
still falls to the next field and not back to the field I tried to
force the focus to. So it seems to me that the browser is
actually tabbing out of the field only after the onChange
script runs.
Now, I can't just use onBlur because a part of my validation
is checking to make sure the field is not blank. So using
onBlur, when I tab out of a blank (or erroneous) field, it
creates an endless loop where to adjacent fields are triggering
their validation script when focus gets placed back to the
erroneous field.
So that brings me back to the onChange. Does anyone
know how I can keep focus on the erroneous field after
the onChange script fires? Because simply forcing focus
on the field doesn't seem to be working.
Thank you for your time and consideration.
thnx,
Christoph
user tabs out of each element. However, I'm having some
problems.
It appears that the order of events is onChange followed
some time afterwards by onBlur. I believe this to be the
case because in my onChange script, if the validation fails,
I force focus back to the field element. However, the focus
still falls to the next field and not back to the field I tried to
force the focus to. So it seems to me that the browser is
actually tabbing out of the field only after the onChange
script runs.
Now, I can't just use onBlur because a part of my validation
is checking to make sure the field is not blank. So using
onBlur, when I tab out of a blank (or erroneous) field, it
creates an endless loop where to adjacent fields are triggering
their validation script when focus gets placed back to the
erroneous field.
So that brings me back to the onChange. Does anyone
know how I can keep focus on the erroneous field after
the onChange script fires? Because simply forcing focus
on the field doesn't seem to be working.
Thank you for your time and consideration.
thnx,
Christoph