All Collections
Fields
Using the Input Field 'Pattern' Feature in Next Plus
Using the Input Field 'Pattern' Feature in Next Plus
Alex Merkin avatar
Written by Alex Merkin
Updated over a week ago

Using the Input Field 'Pattern' Feature in Next Plus

Overview

The 'Pattern' feature in input fields is a vital tool in Next Plus for ensuring that users input the correct type of information. This guide will walk you through how to effectively utilize this feature, leveraging JavaScript regular expressions to define acceptable input patterns.

How to Use the 'Pattern' Feature

  • Defining the Pattern: When setting up an input field, you can define the expected input using JavaScript regular expressions. This can include a range of formats, from numbers and letters to a combination of both.

    • Example: To require a five-digit number, the pattern would be ^[0-9]{5}$, meaning any sequence of five numbers is accepted.

  • Setting a Pattern for Input Fields: To apply a pattern, input the JavaScript regular expression into the Pattern field of the input configuration.

    • Example: For a six-digit number, use ^[0-9]{6}$ as the pattern.

  • Case Sensitivity: It's important to note that the 'Pattern' feature is not case-sensitive.

    • Example: The pattern ^[A-Z]$ will accept both uppercase and lowercase letters.

  • Practical Application: Use the 'Pattern' feature to guide users in providing specific types of information, such as email addresses.

    • Example: For an email, the pattern might be ^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$.

Best Practices and Tips

  • Testing: Always test the pattern to ensure it accurately validates the expected input.

  • Complementary Validation: Remember, the 'Pattern' option is part of a broader validation strategy. Include checks for required fields, character limits, and appropriate data types.

Did this answer your question?