https://jsbin.com/rulapikaya/1/edit?html,js,output
What is the expected behavior?
I created a regex pattern to match letters and numbers. It should accept strings that are any combination of lowercase or uppercase letters, numbers, and spaces.
What is happening instead?
It accepts strings that are just letters and spaces correctly. However, if there is a number in the string, it will invalidate the tag initially. But if you input the string again, it will accept the string. So if you input "Thing 1" it will invalidate it and remove the tag. But inputting "Thing 1" again will work properly. This happens anytime there's a number in the string.
What error message are you getting?
N/A
Note: I got around this on my personal project by modifying the pattern from
/^[a-zA-Z0-9]+$/g to/^[a-zA-Z][a-zA-Z0-9]+$/g
It works for my purposes but these are two different regex patterns
UPDATE: I'm having the same problem with //^[a-zA-Z][a-zA-Z0-9]{0,19}$/g
Looking into it, thanks
You do not need the trailing g in your regex.
/^[a-zA-Z0-9 ]+$/g → /^[a-zA-Z0-9 ]+$/