Mic*_*ael 17 regex validation html5 internet-explorer cross-browser
当输入与pattern属性指定的模式不匹配时,Firefox只会说"请匹配请求的格式",这没关系; 但是,当此验证失败时,Internet Explorer 10会在工具提示中显示"您必须使用此格式:".这可能很简单,但搜索并没有让我知道如何向工具提示提供文本,告诉它应该使用的模式.
以下示例为一到四位数字:
<input id="institution_threshold_days" type="text" placeholder="0-9999" pattern="^[0-9]{1,4}$" />
Run Code Online (Sandbox Code Playgroud)
Dal*_*las 25
尝试使用title属性来描述您想要说的内容:
<input id="institution_threshold_days" type="text" placeholder="0-9999" pattern="^[0-9]{1,4}$" title="Please enter a number less than 10000." />
Run Code Online (Sandbox Code Playgroud)
应该适用于所有主流浏览器......
来自微软
title属性的内容都显示为字段的工具提示文本,并附加到通用模式不匹配错误消息.
来自Mozilla
使用title属性来描述帮助用户的模式.
虽然我找不到官方文档,但它似乎也适用于Chrome.