Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML 5 Hex String for Pattern Attribute

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?

like image 422
waldol1 Avatar asked Oct 29 '25 16:10

waldol1


1 Answers

Only thing shorter is

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

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

More info: RegExp

like image 175
Markus Jarderot Avatar answered Nov 01 '25 08:11

Markus Jarderot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!