I'm trying to replicate the html5 pattern attribute with javascript but getting inconsistent results.
The pattern is [a-zA-Z\. \']+
In Chrome, typing "asd 123" does not pass the test.
Using something like
el.value.match(new RegExp(el.pattern))
lets "asd 123" through, obviously because "asd " is a match.
I can solve this particular problem by adding ^ and $ to beginning and end of my pattern, but the question is this - is there some function out there that is implemented exactly as the pattern attribute? Are there other surprises I should expect?
^-\]still need to be escaped in a character class. Sorry to be pedantic, but I often see SO questions where a-isn't properly escaped or positioned.