masked textfield

Hi, I’m searching how can I mask possible inputs in a textfield (allowing integers only, o decimals, or emails, or credit cards, etc… )

Is it possible with the standard vaadin API to have a mask ? (I’m trying to avoid to have to go to the server to validate if the input is ok)


There’s currently nothing in Vaadin core, no.

For Vaadin 6 there is a published add-on to achieve this :

There is currently published for Vaadin 7, as far as I am aware; in my project, I have implemented a MaskedTextField using jQuery and this
plugin for Masked fields, and a numeric/currency field ComponentExtension using the
jQuery plugin.

Unfortunately, the MaskedTextField is very much skewed towards our use in our project [1]
, and the autoNumeric component extensions is experimental only - so I am not currently in a position to be able to publish them as a Vaadin add-on.

If creating your own component/extension appears to be a little too much for you at the moment, the
add-on allows client-side validation using regular expressions, and has been ported in Vaadin 7. Disclaimer: I haven’t used it.

HTH a little,


Specifically, I have heavily tweaked it to match the Java Swing MaskFormatter, as our existing codebase comes from swing and has masks defined in it’s database, and it also has to to cope with allowing international letters as alphabetic - the jQuery plugin uses regex to perform it’s validation, and javascript doesn’t cope with unicode letters outside of the latin range as letters. I’ve had to frig the regees using some javascript code I found in
this question on StackOverflow