Get access to free tutorials, exclusive content and more.

Limit the Number of Characters or Words in the WordPress Form Field

There are advantages to limiting the number of characters or words in a form field. One benefit is providing a seamless experience by keeping your data clean and easy to manage.

With Ninja Forms you can easily restrict the number of characters or words using the Restriction settings. If you want to go further with restricting form field content, you can use an input mask — another free feature from Ninja Forms. Make sure to check it out!

Now let’s get back to what you came here for!

Table of content

  1. How to limit the number of characters or words in a form field
  2. Practical examples to restrict character/word limit in WordPress forms
  3. Bonus: Define the combination of letters and numbers in the form field

1. How to limit the number of characters or words in a form field

First, you need the form field you are trying to limit the number of characters or words for. The following form fields offer the Restriction settings:

  • Single Line Text field
  • Paragraph Text field
  • Address
  • Anti-spam field
  • Confirm field
  • Zip field
  • Phone field
  • City field

It is important to make sure your Developer Mode is enabled to access Restrictions. If this is on, you will see the Restrictions tab once you open any form field that supports Restrictions settings. Here is what it looks like inside the Ninja Forms form builder:

Restriction Settings

Now let’s look at a few examples when you would consider restricting character/word limit on your online form.

2. Practical examples to restrict character/word limit in WordPress forms

We’ll share three practical examples of using the Restrictions settings with WordPress form fields to limit user input.

Firstly, we’ll demonstrate how to limit the number of words users can input. Next, we’ll show how to restrict the character count in a field. Finally, we’ll guide you through requiring users to enter a combination of letters and numbers into the WordPress form field.

Restrict the word limit in a Paragraph field

Imagine you are running a writing contest and require participants to submit a short story or description. Or, accepting guest posts from your visitors and wanting to adhere to your content length guidelines.

Alternatively, if you have a job application form and don’t want to use the file uploads plugin to allow applicants to upload their cover letters or resumes, you can use the Paragraph Text field and apply the word count limitation to this field.

As an example, we want to collect information about “Why do you want to work with us?” using the Paragraph Text field.

However, sifting through 600 words might be too much. Therefore, we will limit the number of words to 300 using the Restriction settings. This will make it easier for HR to review applications quickly.

limit words in wordpress form field

We also customized the text to appear after the counter to “Words left”. As we type within the text box on the front end, you can see the number of words typed in the bottom left corner (209).

You can also see the maximum number of words displayed (300). If you continue typing over 300 words, it will not allow you to write another word. Keep in mind you can only use the restrictions for characters or words if the Rich Text editor for the Paragraph Text field is disabled. 

restricted words for paragraph text field

Another cool way to use the Paragraph Text field along with Restrictions settings, is when your WordPress site has a feedback form for gathering user suggestions and comments. It’s helpful when you want the feedback to be useful, without being too long.

This is also useful for collecting product reviews, where the goal is to limit the number of words and discourage overly long and verbose reviews.

Limit the character count in a Single Line Text field

You are likely familiar with the “Other” option in an online form. When users have a list of options but none apply. Selecting “Other” allows them to specify their answer in an additional field, as shown below.

other field selection for email unsubscribe reasonThe “Other” field that appears conditionally is a Single Line Text field. Since this field is intended for short answers, we have decided to limit the number of characters users can input in the “Other (Please specify)” field, as shown in the example below.

restrictions for single line text field

We set the limit to 30 characters but decided not to display the customized text. Below, you can see the number of characters (15) typed in as the user writes the answer.

You can also see the maximum number of characters displayed (30). If the user writes more than 30 characters, it does not allow him to continue typing.

limit characters in text field

3. Bonus: Define the combination of letters and numbers in the form field

Besides limiting the number of characters or words in a form field, you can also give instructions on what specific characters you want to allow in your field. The question you might want to ask here is: Do I want to allow numbers only, letters, or both?

The input mask allows you to apply these restriction rules to your form field. In the screenshot below, we demonstrate how to limit users to enter only 7 characters in the form field and set characters to be a combination of numbers and letters.

First, we added the number 7 to “Limit input to this number“. Then we selected Characters and chose Custom from the Input Mask dropdown menu. We typed seven times the asterisk (star) into the Custom Mask. The * gives the direction that characters can be alphanumeric (letters and numbers).

If you only want to allow users to enter 10 characters into a form field that is numbers only, you enter the number 10 into the “Limit Input to This Number” field and type ten times the number “9” into the “Custom Mask” field.
custom input mask numbers only
If you want to allow alpha characters (letters) and limit the number of characters to 8, you will enter the number 8 into the “Limit Input to This Number” and the “a” eight times into the “Custom Mask” field.
letters custom input mask

Do you want to learn more about Input Mask from Ninja Forms? Check out our tutorial How to Use Input Mask in Your Contact Form (Examples)!

The character and word limit with our core plugin is just beginning!

With Ninja Forms’ free core plugin, you can collect unlimited form submissions, view your form submissions, use calculations, and access form actions such as Redirect to URL, Success Message, and Email Notification. You can accomplish so much with our free plugin that you might go years without needing a premium version.

If you decide that the free core is not enough for you anymore, you can explore our integrations that can be purchased individually, unlike other form builders on the market. Enjoy free and powerful form-building and download our core plugin today!