Interface HasAllowedCharPattern

All Superinterfaces:
HasElement, Serializable
All Known Implementing Classes:
ComboBox, ComboBoxBase, DatePicker, EmailField, MultiSelectComboBox, NumberField, PasswordField, TextArea, TextField, TimePicker

public interface HasAllowedCharPattern extends HasElement
Mixin interface for field components that support setting allowed char pattern to prevent user from entering invalid characters when typing or pasting text.
Author:
Vaadin Ltd
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    A regular expression that is used on the client-side to determine which characters the user is allowed to type into the field.
    default void
    Sets a regular expression that is used on the client-side to determine which characters the user is allowed to type into the field.

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement
  • Method Details

    • getAllowedCharPattern

      default String getAllowedCharPattern()
      A regular expression that is used on the client-side to determine which characters the user is allowed to type into the field. Each typed character is matched individually against this expression, and only added to the input if it matches.
      Returns:
      the allowedCharPattern property
    • setAllowedCharPattern

      default void setAllowedCharPattern(String pattern)
      Sets a regular expression that is used on the client-side to determine which characters the user is allowed to type into the field. Each typed character is matched individually against this expression, and only added to the input if it matches. The allowed char pattern must be a valid JavaScript Regular Expression that matches a single character, not the sequence of characters.

      For example, to allow entering only numbers and slash character, use setAllowedCharPattern("[0-9/]")`.

      Parameters:
      pattern - the String pattern to set