Hi can I ask some help please, I have input field and I want to accept only if the beginning has 1100 or 1200

`example: 1100200300`

how can I achieve on this ?

Thank you in advance.

Hi can I ask some help please, I have input field and I want to accept only if the beginning has 1100 or 1200

`example: 1100200300`

how can I achieve on this ?

Thank you in advance.

You can use a regular expression to achieve that without needing any JavaScript at all.

```
<input type="text" pattern="^(1100|1200).*" required>
```

Hi Paul thank you,

Is this will support all browsers?

Hey jemz,

You can easily check that via the Can I use… website: https://caniuse.com/input-pattern

Spoiler alert, the answer is yes (apart from Opera Mini).

HI James, thank you I’m new to this site https://caniuse.com/input-pattern, how can I use the site to test, sorry to ask

Thank you Paul and James. I’ll be back I will try this

Yes of course, you just need to check that there are six other digits, and use the `$`

symbol to say that you expect no more characters after that.

```
<input type="text" pattern="^(1100|1200)\d{6}$" required>
```

Thank you so much paul works now… I missed that symbol and I used {10} instead of 6 I also used the asterisk I’m almost closed to it.

Thank you

Is that because the total length is required to be 14 digits? The 1100 (or 1200) plus another 10?

If the total length is supposed to be 10 digits, then you’ll instead need the initial 4, plus another 6 after that.

By using the asterisk, you are not enforcing a length restriction. They could put in 30 digits without restriction.

The solution that I provided (with the first 4 being checked, and another 6) including the dollar symbol at the end, is for when the length can be no shorter than 10 and no longer than 10. That is, exactly 10 digits long.

Paul! you shared the right post. Thanks