I'm trying to validate a javafx form using ValidationSupport, the validation is working, but when I access the form the "errors decorations" are already shown, even before the form is submitted or the textfield is focused.
ValidationSupport validationSupport = new ValidationSupport();
validationSupport.registerValidator(textField, Validator.createEmptyValidator("Text is required"));
The following image shows an example of the form in its initial state.
How can I force the decoration to show only after the user submit the form or change the TextField value?
To validate controls on demand is an issue (on-demand validation option) on ControlsFx's issue tracker which is still open so ControlsFx does NOT support it yet.
But there is a way to suppress error decorations:
Later, when you actually want to validate (on submit button for example) you need to reset it to default value:
This way, fields still get validated by every change but error decorations are not shown until you actually want them to be shown.
Example:
In this example we'd like to see validation errors only if number field has the focus.
or if you want to see validation errors only after submit button is clicked for the first time: