I am sure that this is a BASIC question for javascript gurus but I'm struggling to resolve.
The form starts with the cursor focus in the FROM ACCT NUMBER FIELD. When I tab to the next field without entering any value in this text field I want to send an alert to the user that the field is required and put the cursor back on that field. I attempted to do that using:
I do get the ALERT however when I click on the OK button on my alert dialog box the alert for the next field call TO ACCT NUMBER FIELD then gets executed because I tabbed to that field and then I get stuck in a loop literally where when I click on the second dialog box it goes back to the first dialog box for the first field.
My question is HOW can I force the cursor back to the FROM ACCT NUMBER FIELD and not execute the alert for the field that I tried to tab to. Is there a better event to use than the .blur event?
I hope this makes sense. Any help/direction would be greatly appreciated.
As you are already using jQuery, I highly recommend the jQuery Validation Plugin which has already solved all the knotty problems. Why re-invent the wheel?
The plugin has lots of nice things about it that would be really hard to do on our own.
For example, once validation messages are displayed, they are individually removed as the user fixes each field that is in error. That's a really nice feature that users really seem to appreciate.