Thanks for the replies. I will have a try with oneditingdone, but what if you are entering, say 4 tedit boxes then enabling an 'UPDATE' button if the data is ok? The user would have to click somewhere after the 4th tedit to trigger validation - doesn't seem very intuitive as far as the use is concerned.
Steve
Well, yes for the 4th button OnEditDone does not work, if in the event you want to execute "ButtonFoo.enabled := true;"
(actually not sure, if "not enabled" includes can not have focus....)
You don't really want a long timer either. As a user, if I typed e.g. my name, I might (want to) hit "tab" immediately. But if the button is not enabled, then where will tab get me to.
One option is to have the button enabled, but pop up an error, if validation fails. Then validation happens in the button.
That of course is a different flow from what you want....
Now do validate as the user types, it depends how much computing validation takes.
If you just need to know if a cell number matches a pattern, then you can do that on every stroke.
You can also shortcut testing, if a minimum length has not been reached yet.
If computing takes longer, you can use Application.QueueAsync... or move it to a thread.
But you would validation need to
- check regularly if it needs to restart (input changed)
- in case of async, running in the main thread: validation needs to give way. That is it needs to store howfar it got, interrupt itself, and continue in a new async event.
Using a timer you have the same issues.
Imagine validation takes 2 seconds or longer.
The use paused typing for just long enough to trigger validation. But now he wants to continue, and the app does not react, as validation is blocking it.....
Either way:
If validation is quick -> do it directly in OnChange
If it is slow, then think about what happens if the user wants to tab to the button.