Don’t focus the Textfield, just click on the Button ‘Save’.
At the console of the development environment appears the message ‘PLZ is valid.’ although it’s wrong.
Click to the TextField.
Click to ‘Save’.
At the console of the development environment appears the message ‘PLZ is valid.’ although it’s wrong.
Insert the digit 3 into the TextField and afterwards click ‘Save’.
The UI shows now the red error message ‘PLZ needs exact 5 digits.’. The same message appears at the console of the development environment.
Insert the number 33333 into the TextField and click ‘Save’.
The red error message at the UI disappears but at the console of the development environment appears no message of the listener.
Click again ‘Save’.
Now the message ‘PLZ is valid.’ appears at the console of the development environment.
My questions:
How do I have to implement the validation so that the steps 2-5 will be solved correct, to be specific:
a. Show the error message after click at ‘Save’ although there was no focus at the TextField.
b. Show the error message after click at ‘Save’ although there is no entry at the TextField and the focus was at the TextField.
The message ‘PLZ is valid.’ should appear at the console after only one click at ‘Save’ for the situation described at steps 8-11. How can I avoid clicking twice?
Given that field validation exists though, I wonder why it’s not possible to trigger validation manually to support this use case. It looks like it should be possible to call textField.validate() and have it update the invalid state.
Thank you for your answer. I also tried my example with the Binder, but it didn’t work or I made a mistake, I don’t n know. For the current update, I would prefer, not using the Binder because there are too many changes at the code of our big project that have to be done. In future, it will be an option, that we use it, but not for now.