0

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

TextField price = new TextField();
ValidationSupport validationSupport = new ValidationSupport();
masterofdisaster
  • 1,079
  • 1
  • 12
  • 27

1 Answers1

1

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.

Bourbia Brahim
  • 14,459
  • 4
  • 39
  • 52
Adam Ostrožlík
  • 1,256
  • 1
  • 10
  • 16
  • 1
    Dead link. BTW the ControlsFX documentation varies between non-existent and shithouse. – Dave May 19 '21 at 03:20