Skip to content

Wrong regexp in TextField.setPattern example #3296

Closed as not planned
Closed as not planned

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.

Activity

  1. javier-godoy commented on Nov 10, 2026

    @javier-godoy
    ContributorAuthor

    Closing as part of a personal cleanup of projects I'm no longer involved in. This does not imply that the underlying issue has been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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