masterofdisaster
masterofdisaster

Reputation: 1159

ControlsFX TextField validation

How can I validate the text field to be contained only float values using ControlsFX validator?

TextField price = new TextField();
ValidationSupport validationSupport = new ValidationSupport();

Upvotes: 0

Views: 1201

Answers (1)

Adam Ostrožlík
Adam Ostrožlík

Reputation: 1416

Please, read this documentation

All you need to do is this type of code where you bind validator with TextField:

ValidationSupport validationSupport = new ValidationSupport();
validationSupport.registerValidator(textField, Validator.createEmptyValidator("Text is required"));

Instead of Validator.createEmptyValidator you have to create validator using Regex expresion / Pattern like this: ^[-+]?[0-9]*\.?[0-9]+$

Then you can validate your text.

Upvotes: 1

Related Questions