Skip to content
Advertisement

How to limit the number of multiple characters in an input value?

I want to limit the number of letters at the beginning and end of the input value (e.g. QQ23F and SG21G) through JavaScript but I found that only one {} can be written in a pattern. Thanks for any help. Here is my incorrect code:

JavaScript

Advertisement

Answer

You need to add the begging ^ and end $ signs

JavaScript

And for everyone’s sake use let not var

Advertisement