I am trying to validate two Textfield
s in javafx on a button click, I am using ControlsFX to do this. Here is my validation code:
private void applyValidationSupprot() {
ValidationSupport support = new ValidationSupport();
support.registerValidator(userName, false, (Control control, String value) ->
ValidationResult.fromErrorIf(userName, "Required", isValid)
);
support.registerValidator(password, false, (Control control, String value) ->
ValidationResult.fromErrorIf(password, "Required", isValid)
);
}
userName
and password
are my Textfield
s and isValid
is a variable declared previously, and my button's onAction
event is bound to this method:
public void validate() {
isValid = true;
}
But when I click the button the validation do not happen. Where is the problem?
Reminder: I do not how to make validation with createEmptyValidator
but I want my validation to happen on my button click.