Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tricky OnExit and SetFocus problem.
#3
Hi MrSpock,

Thanks for your input. Checking for an empty field at exit and return the cursor to the field with SetFcus, was to make sure a field is filled in before sending the form. But as you say, it also means the users do not have any control, and in fact I had it set up so that if a field content was not correct, setfocus was called to return the cursor to the field. It means it is not only when the field is empty, also when the contents is false.

So I have done as you suggested: keep a list of booleans, one for each field, being set in the OnExit to true when everything is ok, and to false if, for what ever reason, the contents is false (empty, wrong, whatever). And if a field is false I set the color to red with white font, to easily spot which field is not correct. In the OnKeyDown I reset the color to standard.

And finally, at the time to send the form (save the data) I check to see that all booleans in my list is true. And if not, I abort saving and place the cursor at the wrong field.

Also I have enhanced the function with a message field, telling the user the reason for why a field is red, and that too, is removed at the first keydown.

It might not be 100% fail safe but as far as I can test, it works, and allows the users to fill in the field in any order they want.

I'm sure that if I had a little more JS experience, I could do most of it directly in the client. As it is now, I do it on server side, though with the OnAsyncXXXX events.

Regards
Soren
Reply


Messages In This Thread
RE: Tricky OnExit and SetFocus problem. - by SorenJensen - 01-30-2020, 02:29 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)