Closed
Bug 1121945
Opened 11 years ago
Closed 11 years ago
Mismatch for <input pattern="\S+">
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: bruant.d, Unassigned)
Details
Not sure what the proper component is. I did my best. Change component as you find appropriate.
Steps to reproduce:
1) Create a document with <input pattern="\S+">
2) type " a" (space followed by the letter "a")
3) remove focus from the input
What happens:
The value is considered invalid
Expected:
The value should be a valid given " a".match(/\S+/) doesn't return null (and the pattern attribute is supposed to follow JavaScript regexps)
Comment 1•11 years ago
|
||
Looking at our pattern attribute handling, it takes the value of the pattern attribute and prepends "^(?:" to it and appends ")$" to it. Clearly /^(?:\S+)$/ doesn't match " a".
The relevant spec is at https://html.spec.whatwg.org/multipage/forms.html#the-pattern-attribute and says:
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.
and then has an informative note:
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).
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → INVALID
| Reporter | ||
Comment 2•11 years ago
|
||
I should have read the spec first, sorry :-s
pattern="\s*(\S+\s*)+" does the job
| Assignee | ||
Updated•6 years ago
|
Component: HTML: Form Submission → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•