3

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?

4

1 回答 1

7

Only thing shorter is

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

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

More info: RegExp

于 2013-07-07T21:12:17.767 回答