I want to validate the data entered into a form text field by calling a
function with onblur, doing the validation and, if the input is invalid,
giving an alert to the user and returning focus and select to the invalid
field to force the user to correct the entry.
A simple example is at www.brilley.co.uk/TestInfo.htm
The problem is that this example works in IE but not in NN or Safari, which
do not return focus or select back to the text field.
I understand that many think it is not good practice to force the user back
to the field so that she has to correct it before she can progress, but I
think the application I have to design would be best served by this
approach.
Clearly, the way I have coded it is either in error, or that's how NN and
Safari are designed. You can focus on another field but not on the one that
called the event, it seems.
I'd very much appreciate any help on either fixing my code or another way of
producing the same result. In the real application it's not practical to
validate on submit because there are many validations on the same page,
which I think leads to confusion. Better to validate each field one at a
time.
Thanking you in anticipation.