### [How to Change the Limit Character Validation Text](https://wpforms.com/developers/how-to-change-the-limit-character-validation-text/)

**Published:** May 8, 2020
**Author:** Editorial Team

**Excerpt:** This tutorial will walk you through how to change the limit character text that appears when using the Limit Character or Limit Words option on your text fields using PHP. 

**Content:**

Curious about altering the character limit text shown beneath your form fields, especially when employing the **Character Limit** on **Single Line Text** or **Paragraph Text** form fields?

By default, you’ll notice a message below the form field indicating the current character count out of the maximum limit, such as *0 out of 50 max characters* or *0 out of 50 max words*, depending on your form settings. You can personalize this message to include the count of remaining characters. This adjustment is easily accomplished with a simple PHP snippet. In this tutorial, we’ll walk through how to utilize PHP to alter this message.

## Creating the form

First, we’ll need to create our form and add our form fields.

If you need any help in creating your form, [please check out this documentation](https://wpforms.com/docs/creating-first-form/ "How to Create Your First Form").

![add your fields to your new form](https://wpforms.com/wp-content/uploads/2020/05/wpforms-create-form-limit-character.jpg)

We’ve added a **Paragraph Text** form field to hold our engraved message.

## Setting the character limit

Next, select the **Paragraph Text** you added and click on the **Advanced** tab to enable the **Limit Length** option and set the limit to **100** and select **Character** from the dropdown.

![enable the Limit Length option on the Advanced tab](https://wpforms.com/wp-content/uploads/2020/05/wpforms-set-character-limit.jpg)

For further information on the **Limit Length** option, [please review this documentation](https://wpforms.com/docs/how-to-limit-words-or-characters-in-a-form-field/ "How to Limit Words or Characters in a Form Field").

## Changing the limit character validation text

Now it’s time to add the snippet to your site.

If you’re not sure how or where to add snippets to your site, [please check out this tutorial](https://wpforms.com/developers/how-to-add-custom-php-or-javascript-for-wpforms/ "How to Add Custom PHP or JavaScript for WPForms").

```

/**
 * Change the text for the character limit.
 *
 * @link https://wpforms.com/developers/how-to-change-the-limit-character-validation-text/
 */

function wpf_dev_frontend_strings( $strings ) {
	
    // val_limit_words when using words
    // val_limit_characters when using characters   
    
    // Change the message that will appear to your visitors after the = sign below
    $strings[ 'val_limit_characters' ] = __( 'You have used {count} characters out of allotted {limit}. You have {remaining} remaining.', 'plugin-domain' );

	return $strings;
}

add_filter( 'wpforms_frontend_strings' , 'wpf_dev_frontend_strings', 10, 1 );

```

![with this snippet users can see how many characters they have left from the character limit](https://wpforms.com/wp-content/uploads/2020/05/wpforms-change-character-limit-text.jpg)

And that’s it! You’ve successfully changed the limit character text that shows under the form field when using the character or word limit. Would you also like to also have a minimum number of characters set for your form field? Take a look at our tutorial on [How to Set a Minimum Number of Characters on a Text Form Field](https://wpforms.com/developers/how-to-set-a-minimum-number-of-characters-on-a-text-form-field/ "How to Set a Minimum Number of Characters on a Text Form Field").

## Reference Filter

[wpforms\_frontend\_strings](https://wpforms.com/developers/wpforms_frontend_strings/ "Using the wpforms_frontend_strings filter")

## FAQ

#### Q: How would I change the text when using Word limit and not Character limit?

**A:** To change the text for the Word limit, please use the following code snippet:

```

/**
 * Change the text for the character limit.
 *
 * @link https://wpforms.com/developers/how-to-change-the-limit-character-validation-text/
 */

function wpf_dev_frontend_strings( $strings ) {
	
    // val_limit_words when using words
    // val_limit_characters when using characters   
    
    // Change the message that will appear to your visitors after the = sign below
    $strings[ 'val_limit_words' ] = __( 'You have used {count} words out of allotted {limit}. You have {remaining} remaining.', 'plugin-domain' );
	return $strings;
}

add_filter( 'wpforms_frontend_strings' , 'wpf_dev_frontend_strings', 10, 1 );

```

#### Q: Can I change this for both words and characters in one function? 

**A:** Absolutely! You can change this text for both words and characters in one single function by using this snippet.

```

/**
 * Change the text for the character and word limit.
 *
 * @link https://wpforms.com/developers/how-to-change-the-limit-character-validation-text/
 */
  
function wpf_dev_frontend_strings( $strings ) {
      
    // val_limit_words when using words
    // val_limit_characters when using characters   
      
    // Change the message that will appear to your visitors after the = sign below
    $strings[ 'val_limit_words' ] = __( 'You have used {count} words out of allotted {limit}. You have {remaining} remaining.', 'plugin-domain' );
    $strings[ 'val_limit_characters' ] = __( 'You have used {count} characters out of allotted {limit}. You have {remaining} remaining.', 'plugin-domain' );
    return $strings;
}
  
add_filter( 'wpforms_frontend_strings' , 'wpf_dev_frontend_strings', 10, 1 );
```

#### Q: Can I remove the text that shows completely? 

**A:** You can, of course, remove this message. But keep in mind, if you’re visitors are typing and then suddenly can’t type anymore due to the limit, this could cause confusion when completing the form. We recommend leaving some sort of message explaining the limit. However, if you’d still like to remove the message that appears completely, use this snippet instead.

```

/**
 * Remove the text for the character and word limit.
 *
 * @link https://wpforms.com/developers/how-to-change-the-limit-character-validation-text/
 */
 
function wpf_dev_frontend_strings( $strings ) {
     
    // val_limit_words when using words
    // val_limit_characters when using characters   
     
    // Change the message that will appear to your visitors after the = sign below
    $strings[ 'val_limit_words' ] = '';
    $strings[ 'val_limit_characters' ] = '';
    return $strings;
}
 
add_filter( 'wpforms_frontend_strings' , 'wpf_dev_frontend_strings', 10, 1 );
```

**Categories:** Extending

**Tags:** PHP

---

