HTML 5 Hex String for Pattern Attribute

hex, html, regex, validation

Solution

Only thing shorter is

<input pattern="[a-fA-F\d]+"/>

The `\d` character class is equivalent to `0-9`.

More info: RegExp

Problem

I have several form elements that accept hex strings like the one shown below. ``` <input type="text" name="..." onkeyup="a('...')" pattern=\"[a-fA-F0-9]+\" value=\"****\"/> ``` I am interested in shorting the pattern attribute value to something shorter, but still accept the same pattern. I am doing this because this html is embedded in a micro controller and saving space is desirable. Is there a predefined cross browser hex matching class?

Original source