> For the complete documentation index, see [llms.txt](https://deltaclan.gitbook.io/superform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://deltaclan.gitbook.io/superform/input-validation-and-errors/validation/words.md).

# words()

Ensure the input contains a specific range of words.

## Setup

**Attribute**: `sf-validation="words(MIN_WORDS, MAX_WORDS)"`

Ensures that the input contains a specific range of words. This is particularly useful for fields like comments, descriptions, or any input where word count matters.&#x20;

For example, you can require a user to enter between 5 and 20 words to ensure sufficient detail without overwhelming verbosity.

{% hint style="info" %}
Please note: `words()` validation should be applied to the following input types: `text`, `textarea`, `search`, `url`.

{% endhint %}

**HTML Example**

{% code title="index.html" %}

```html
<!-- Form Container -->
<div sf="myForm">
    <form>
        <!-- Textarea with Words Validation -->
        <div sf-step="step1">
            <label for="inputText">Enter your text:</label>
            <textarea name="inputText" id="inputText" sf-validation="words(0,3)" required></textarea>
            <div class="text-style-error">Text must be a maximum of 3 words.</div>
            <button sf-goto="next">Next</button>
        </div>
    </form>
</div>
```

{% endcode %}

**Webflow Example**

<figure><img src="https://450000313-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDGLtnaQr6bP3qHCWvX0r%2Fuploads%2FBUKCqEBtUuvru6z6aZKm%2FCleanShot%202024-07-07%20at%2013.41.09%402x.png?alt=media&amp;token=832b5cdd-34ae-4287-a8ed-33d762cdaabc" alt=""><figcaption><p>Adding <code>sf-validation = words(0,3)</code> to a &#x3C;textarea> element.</p></figcaption></figure>

***

## Usage Examples

* `words(0,10)`: Minimum of zero words are allowed, and the maximum number of words can be up to 10.
* `words(5)`: Minimum of 5 words are required, with no restriction on the maximum number of words.

***

## Attribute Configuration

Make sure to add the `sf-validation="words(MIN_NUM,MAX_NUM)"` attribute key-pair to valid input types as mentioned above.&#x20;

Here are some instructions to keep in mind:

* The attribute value should follow the format `words(MIN_NUM,MAX_NUM)` or `words(MIN_NUM)`.
* `words()` validation can be paired with native HTML attributes like `pattern`.

{% hint style="info" %}
**Dos and Don'ts**

***

Do ✅

* `words(2,100)`
* `words(2)`

Don't ❌

* `words(any,100)`: Don't use alphabetic characters as arguments; only numbers are allowed.
* `words(10 , 10)`: Don't use spaces.
* `words(2.5 ,15.5)`: Don't use fractional numbers.
* `words(1,2,3)`: Don't use more than 2 arguments.

{% endhint %}
