Solution type to restrict specific characters in a TextField

Hi, I wonder if it is worth opening an issue tracker to restrict specific type characters in a TextField.

In the TextField add in the constructor method a variable allowOnlyCharacters:

public TextField(String caption, String value, String allowOnlyCharacters)

And in the VTextField add a KeyPressHandler in the updateFromUIDL method:

addKeyPressHandler(new KeyPressHandler()
 public void onKeyPress(KeyPressEvent event)
  if (!VTextField.this.[b]

This is a useful feature to lock the field to certain characters.


support your use case?


He inserts “___” in the fields.

It should be pretty easy to modify the
method to remove the underscores and special chars from the field. Perhaps it’s enough to remove the setValue call on line 179?

However, you are of course free to open a new ticket in
our issue tracker
if you wish. Unfortunately there are no guarantees as to whether the ticket actually will be implemented. Patches and/or contributions are of course also accepted, but in this case I think that an add-on actually would be the place to start.

Perhaps the author of MaskedTextField also would consider adding an option for whether to display the pattern or not.


There’s also the
that does what you want.

I can not find a solution for my problem. I want a Textfield where i can enter only numbers and DecimalSeperator “,”.

I am using vaadin 7.7.13. Is there any way to handle this?