title: How to use JFoenix RequiredFieldValidator to enable/disable form JFXButton?
body: <p>I'm using JFoenix to create a login form, my form do have a text field and a Password Field <a href="https://i.stack.imgur.com/xKXPH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xKXPH.png" alt="as you see validation is okey :) "></a> </p>
  
  <p>What I'm trying to do, is to disable/enable automatically the "Connecter" button according to the validation of the two field</p>
  
  <p>below my code</p>
  
  <pre><code>RequiredFieldValidator requiredFieldValidator ;
  private void setupValidation() {
      requiredFieldValidator = new RequiredFieldValidator();
      requiredFieldValidator.setIcon(new ImageView(getClass().getResource("/icons/errors/invalid.png").toString()));
      requiredFieldValidator.setMessage("champs obligatoire");
  
      userName.getValidators().add(requiredFieldValidator);
      userName.focusedProperty().addListener((ObservableValue&lt;? extends Boolean&gt; observable, Boolean oldValue, Boolean newValue) -&gt; {
          if (!newValue) {
              userName.validate();
          }
      });
  
      requiredFieldValidator = new RequiredFieldValidator();
      requiredFieldValidator.setIcon(new ImageView(getClass().getResource("/icons/errors/invalid.png").toString()));
      requiredFieldValidator.setMessage("champs obligatoire");
      password.getValidators().add(requiredFieldValidator);
      password.focusedProperty().addListener((ObservableValue&lt;? extends Boolean&gt; observable, Boolean oldValue, Boolean newValue) -&gt; {
          if (!newValue) {
              password.validate();
          }
      });
      requiredFieldValidator = new RequiredFieldValidator();
      requiredFieldValidator.setIcon(new ImageView(getClass().getResource("/icons/errors/invalid.png").toString()));
      requiredFieldValidator.setMessage("champs obligatoire");
      passwordConfirm.getValidators().add(requiredFieldValidator);
      passwordConfirm.focusedProperty().addListener((ObservableValue&lt;? extends Boolean&gt; observable, Boolean oldValue, Boolean newValue) -&gt; {
          if (!newValue) {
              passwordConfirm.validate();
          }
      });
  
  }
  </code></pre>
  
  <p>If you believe that there is a better way to do so, I'm open to any suggestion.</p>
  
  <p>Thanks.</p>