I have a form with multiple input boxes. I want to validate each input
box (and force user to correct it) before allowing user to move to
another, either using tab key or a mouse click.
I try onchange/on blur to activate a javascript function to check the
input for correctness once user moves out of the input box (tab or mouse
click). If it looks OK, then nothing happens. But if an error is
detected, the function puts out an alert box and then use focus() and
select() methods to bring the focus back to the error'ed input box.
The result of the coding is that the error'ed input was selcted, but the
cursor still goes to the NEXT input box. It looks like the focus()
method did not last.
I suspect that the mouse click event still takes place after focusing on
the error'ed input box.
My question then is: Is there a way to stop that, and keep the focus on
the error'ed box? I really do not like to validate all the input boxes
AFTER the user enters all the inputs.
Thanks for the help.