I have a system that I want to migrate to vaadin 8. I wanted to request for assistance on how to validate a TextField based on regular expressions. I have code that works for Vaadin 7 but not Vaadin 8 which could further explain what I am asking. A code sample like below would be highly appreciated.
TextField txtFirstname = new TextField();
txtFirstname.setInputPrompt("Enter the firstname e.g. John or Jane");
txtFirstname.addValidator(new RegexpValidator("^[a-zA-Z _\\-'\" ]{3,25}$", "Invalid FirstName"));
txtFirstname.addBlurListener(new BlurListener() {
@Override
public void blur(BlurEvent event) {
//txtFirstname.validate();
if(txtFirstname.isValid()==false)
{
txtFirstname.setValidationVisible(true);
//txtFirstname.focus();
}
else if(txtFirstname.isValid()==true)
{
txtFirstname.setValidationVisible(false);
}
}
});