docs icon indicating copy to clipboard operation
docs copied to clipboard

Wrong regexp in `TextField.setPattern` example

Open javier-godoy opened this issue 1 year ago • 0 comments

The regular expression in https://vaadin.com/docs/latest/components/text-field#constraints is wrong https://github.com/vaadin/docs/blob/0732f33ae30d12bf19c6d44a98630e30cff1b646/src/main/java/com/vaadin/demo/component/textfield/TextFieldConstraints.java#L17

image

Compare:

    TextField f4 = new TextField();
    f4.setPattern("^[+]?[(]?[0-9]{3}[)]?[-s.]?[0-9]{3}[-s.]?[0-9]{4,6}$");

    TextField f5 = new TextField();
    f5.setPattern("^[+]?[\\(]?[0-9]{3}[\\)]?-?\\s*[0-9]{3}-?\\s*[0-9]{4,6}$");
    add(f4, f5);

Only the second field performs native client-side validation

image


If you think this issue is important, add a 👍 reaction to help the community and maintainers prioritize this issue.

javier-godoy avatar Mar 15 '24 17:03 javier-godoy