模式属性的HTML 5十六进制字符串 [英] HTML 5 Hex String for Pattern Attribute

查看:155
本文介绍了模式属性的HTML 5十六进制字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < input type =text我们有几个表单元素可以接受如下所示的十六进制字符串。 name =...onkeyup =a('...')pattern = \[a-fA-F0-9] + \\value = \**** \/ > 

我有兴趣将模式属性值缩短为更短,但仍然接受相同的模式。我这样做是因为这个html嵌入在微控制器中,并且节省空间是可取的。是否有预定义的跨浏览器十六进制匹配类?

解决方案

只有短的是

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

\d 字符类是等效的至 0-9



更多信息:正则表达式


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?

解决方案

Only thing shorter is

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

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

More info: RegExp

这篇关于模式属性的HTML 5十六进制字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆