Right now I can set a specific length, or a range, but not two different lengths, both valid.
pattern=”{11}” <-One specific length
pattern=”{11,15}” <-Range
How do you get it to accept only 11 or 15 but nothing else? No 12, 13, 14, 5, etc.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The pattern attribute is based on regular expressions. RegEx {} checks for character occurences (in your case 11 and 15).
You can’t check for exactly two different (non-adjacent) lengths with one expression and one {} notation.
You would need to write two expressions: the first one checks for 11 characters and the second one for 15 characters. You can chain these two regular expressions with some conditionality. Some If-else-conditionality exists, but may not be supported by the browsers.