Retrict Empty Spaces in TextField

How to restrict Empty (Blank)Spaces in TextField


If you want to remove spaces before and after your words you can use the trim property and it is enabled by default.

If you have String in your TextField, it would be better to use formatter (see documentation) and handle spaces with your custom logic. For instance:

textField.setFormatter( value -> {
    String stringValue = (String) value;
    // handle spaces;
    return stringValue;

Also, you can check Datatype. It can be used in the entity attribute or set in the certain textField. Example of a custom datatype.