Skip to content

Wrong regexp in TextField.setPattern example #3296

Open
@javier-godoy

Description

@javier-godoy

The regular expression in https://vaadin.com/docs/latest/components/text-field#constraints is wrong

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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions