I've seen mostly examples without the ^ (circumflex) and $ (currency or dollar) characters to mark the beginning an end of the string being matched. However, I did not find anything regarding this in the html5 spec. Are they implicit in the pattern? The html5 spec states that they are implicit.
The compiled pattern regular expression, when matched against a string, must have its start anchored to the start of the string and its end anchored to the end of the string. This implies that the regular expression language used for this attribute is the same as that used in JavaScript, except that the pattern attribute is matched against the entire value, not just any subset (somewhat as if it implied a ^(?: at the start of the pattern and a )$ at the end).
In type="text" inputs, the pattern works fine using either format, however in type="tel" inputs, I had to remove the characters for the regex to work as expected. I've tested in both Opera and Firefox.
Is this a browser bug? Should I file a bug in bugzilla etc.?
Edit: It seems that I've stumbled uppon a weird bug, because I'm unable to create a reduced test case. A simple input in a page doesn't shows the behavior stated above. However, the question remains. Should I, or should I not use the darn ^ and $ anchors?
tel
input: Line breaks are automatically stripped from the input value, but no other syntax is enforced, because telephone numbers vary widely internationally. You can use attributes such as pattern and maxlength to restrict values entered in the control.. It does not mention anything specific about thetel
type in itspattern
attribute description. – Anatropoustel
inputs. Could you give a full example including code, what you expected, and what you got instead? – Anatropousinput
element it concerns? And please provide a link then you refer to a specification (I hope it's from W3.org) – Anatropous^
and$
are implied. This means that you do not need to put them there explicitly. – Anatropous