Question: So I have a `textarea` and am doing some front-end validation on it with jQuery and Regex.

The criteria for the input are as follows:

* must have 5-12 characters
* cannot contain any special characters
* needs at least one number

it is the last point that I am struggling with.

This is how I am validating the first two criteria:

```
if (charsLength < 5 || charsLength > 12) {
                       alert("Please ensure your Unique ID is between 5 and 12 characters.");
                   }
                    if(/^[a-zA-Z0-9- ]*$/.test(uniqueIDContent) == false) {
                        alert('Your Unique ID contains illegal characters.');
                    }

```

Thanks in advance

Answer: 
You can use a look-ahead to ensure that a certain condition is true in the following string. 

In this case, that condition is *"at least one decimal digit anywhere in the string"*, i.e. `(?=.*\d)`.

Therefore we get:

```
^(?=.*\d)[ a-zA-Z0-9-]{5, 12}$

```

This expression also includes the length check.

**Note** If you want to allow `-` in a character class, get into the habit of making it either the very first or very last character, to prevent inadvertently creating a range.
u would try it
at least a number :)

```
^(?=.*\d)+[a-zA-Z0-9]{5,12}

```