
July 15th, 2004, 04:23 AM
|
|
Contributing User
|
|
Join Date: Jul 2004
Posts: 65
Time spent in forums: 37 m 32 sec
Reputation Power: 4
|
|
Please Please Help
I have a form in which 2 fields need to be populated in order for a value to be generated. Once the second field is populated the code runs to generate the value. (It runs on the change event of field 2). This is fine if a user fills the fields in the right order. But if they don't it all goes wrong.
So, user comes in and focus is on field 1 but instead of selecting field 1, they leave it blank and move on to field 2. On the lost focus event of field 1, I've added a statement which says if field 1 is null, return focus to it, put out a message saying populate field one. The idea is that they can't get off field 1 without populating it, therefore they will always fill everything in in the right order and the value i need will be generated. I've then made field 2 mandatory, so it has to be changed and the code has to run.
However, at the point where I re-set the focus to field 1 on the lost focus event, it does not re-set the focus. It leaves the focus on the second field (which is a combo box) and allows the user to poulate that field while field 1 is still null, hence no value generated.
How do I force the user to populate the first field before they populate the second? What am I doing wrong?
|