Hello!
I'm trying to set up a regex validation between 6-7 characters that could be either numbers or letters, I was trying to work with this code:
[a-zA-Z0-9]{6,7}
But the code isn't validating, it's letting anything in. Can someone let me know what's wrong with the above?
Solved
Alpha Numeric Validation with a set character range
Best answer by ahmedA
You are not enforcing a string length, therefore, even if the text is 100 chars long, as long as it had a sequence of 6 or 7 letters and numbers, it'll pass.
Add the start of and end of string tokens to get it to work:
^[a-zA-Z0-9]{6,7}$
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.