我需要使用密码和密码确认来验证简单的JavaFX表单。ControlsFX复杂验证
validationSupport.registerValidator(passwordInput,
Validator.createEmptyValidator("Password required!"));
validationSupport.registerValidator(confirmPasswordInput,
new EqualsToValidator(passwordInput.textProperty(),
"Password differs from confirmation"));
在EqualsToValidator我简单地比较property.getValue()
和value
传递给验证。
如果我改变只密码EqualsToValidator
是不调用,因为它是听confirmPasswordInput
不passwordInput
。
我只发现了丑陋的解决方案:
passwordInput.textProperty().addListener((observable, oldValue, newValue) -> {
String oldText = confirmPasswordInput.getText();
confirmPasswordInput.setText(null);
confirmPasswordInput.setText(oldText);
});
如何一个字段时,另一个领域的变化无效?
好吧,看起来验证不是那么复杂。我写了我自己的简单验证器。 –
请在评论或回答部分写下您的解决方案,以便具有相同问题的人员可以获得解决方案。 – Maxoudela
您是否找到了使用ValidationSupport的方法? – dinhokz