Based on my testing, the HTML5 template attributes support Unicode character code characters in the same way that JavaScript does and does not :
- It only supports
\u notation for Unicode code points, so \u00a1 will match '& iexcl;'. - Since they define characters, you can use them in character ranges, for example
[\u00a1-\uffff] . will also match Unicode characters.
You don’t actually indicate how you want to pre-test, so I can’t help you anymore, but by looking at the Unicode character icons you should be able to work out what you need in your regular expression,
Keep in mind that regexing a pattern is pretty stupid in general and not universally supported. I recommend a progressive improvement with some javascript on top of the template value (you can even reuse the regex more or less).
As always, never trust user input. It doesn’t take a genius to query your form endpoint and convey more or less any data that they like. Your server-side check must necessarily be more explicit. Your client-side verification may be more generous, depending on whether false positives or false negatives are more problematic for your use.
source share