1

I am trying to validate two Textfields 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 Textfields 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.

Ayoub.A
  • 1,943
  • 3
  • 27
  • 34
  • ControlsFx does not support on-demand validation. If you're trying to suppress error messages shown on every text change event and trigger them on button click, see [this](http://stackoverflow.com/questions/41603284/validate-javafx-form-only-after-submission-using-validationsupport) post. – Omid Jan 20 '17 at 23:57
  • good. why don't you add this as an answer – Ayoub.A Jan 21 '17 at 06:12

0 Answers0