Would you like to limit the number of words or characters that a user can enter into certain fields in your form? Long entries can be hard to review and sometimes may not fit your goals for a form.
This tutorial will show you how to easily restrict the length of Single Line Text and Paragraph Text fields.
Before getting started, you’ll first need to make sure WPForms is installed and activated on your WordPress site and that you’ve verified your license. Then, you can create a new form or edit an existing one to access the form builder.
Adding a Character or Word Limit
Once your form builder is open, be sure to add either a Single Line Text or Paragraph Text field. For this example, we’ll add a Paragraph Text field.
Now, click on this field in the preview area to open its Field Options.
Within the Field Options panel, click on the Advanced tab to open the field’s advanced options.
Then, to limit the number of characters or words, select the Limit Length option.
When you enable this option, two additional fields will display:
- Number Input: Enter a numeric value to use as the maximum limit.
- Characters and Words Dropdown: Choose whether you’d like to limit by the number of individual characters or words.
Note: If you’ve chosen to limit the length by Characters, keep in mind that spaces, periods, commas, etc. all count toward the total character limit.
For our example, we’ll limit our field to 100 characters.
After setting up these options how you’d like, be sure to save your form.
Note: To prevent users from entering special characters in Single Line Text and Paragraph Text fields, you can apply certain restrictions using a PHP snippet. For instructions on how to set this up, see our developer documentation.
Testing Your Form
For the last step in this setup, we recommend testing your form so you can check that it looks and works how you’d like. Our detailed guide on testing forms shares a checklist of recommended steps to consider before publishing your forms.
For this particular feature, the main thing you should notice when testing your form is the text showing how many words or characters are allowed, and how many have been used.
Once the limit is reached, the user will not be able to enter any additional characters in this field.
Note: For advanced field customization, consider using custom input masks to define and restrict the format of the entry. Learn how to implement this in our guide on using custom input masks in WPForms.
Frequently Asked Questions
Below, we’ve answered some of the most common questions we receive regarding limiting words or characters.
Can I set a minimum number of characters for text input on my forms?
Yes, you can enforce a minimum character count for Single Line Text, Paragraph Text, and Password fields. For detailed instructions on setting a minimum character limit, please refer to our developer documentation.
Note: Please be aware that this requires advanced functionality, such as adding code to your site, and is therefore recommended for developers.
That’s it! You can now limit the number of words or characters that a user can enter into your Single Line Text and Paragraph Text fields.
Next, would you like to customize your form’s automatic notification emails? Notification emails can easily include a header logo, custom background color, and custom content. Be sure to check out our tutorial on setting up notification emails for all the details.