加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式 – 如何使用自定义工具提示文本输入无效模式,而不是

发布时间:2020-12-14 06:27:41 所属栏目:百科 来源:网络整理
导读:当输入与pattern属性指定的模式不匹配时,Firefox简单地说:“请匹配请求的格式”,这是可以的;但是,当此验证失败时,Internet Explorer 10将显示“您必须使用此格式:”,在其他任何工具提示中.这可能很简单,但搜索并没有给我一个线索,如何提供文本的工具提示告
当输入与pattern属性指定的模式不匹配时,Firefox简单地说:“请匹配请求的格式”,这是可以的;但是,当此验证失败时,Internet Explorer 10将显示“您必须使用此格式:”,在其他任何工具提示中.这可能很简单,但搜索并没有给我一个线索,如何提供文本的工具提示告诉它应该使用的模式.

下面列出一到四位数字的示例:

<input id="institution_threshold_days" type="text" placeholder="0-9999" pattern="^[0-9]{1,4}$" />
尝试使用title属性来描述你想要的内容:
<input id="institution_threshold_days" type="text" placeholder="0-9999" pattern="^[0-9]{1,4}$" title="Please enter a number less than 10000." />

应该适用于所有主流浏览器…

从Microsoft

the content of the title attribute is both shown as tooltip text for
the field and appended to the generic pattern mismatch error message.

从Mozilla

Use the title attribute to describe the pattern to help the
user.

尽管我找不到官方文档,但它似乎也可以在Chrome中使用.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读