HTML5 输入模式在输入类型=“数字"中不起作用 [英] HTML5 input pattern not working in input type="number"

查看:30
本文介绍了HTML5 输入模式在输入类型=“数字"中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 input type="text" 中使用了输入模式它的工作代码

I used input pattern in input type="text" its working its working code

<input name="name" required pattern=".{4,}" title="Please Enter Correct Name" type="text" />

但是当我在 input type="number" 中使用输入模式时,它不起作用

But when I used input pattern in input type="number" its not working

<input name="number" required type="number" pattern=".{9,20}" title="Please Enter Your Number at least 9 Digit" />

推荐答案

来自 MDN

用于检查控件值的正则表达式.模式必须匹配整个值,而不仅仅是某个子集.使用 title 属性来描述模式以帮助用户.当 type 属性的值为 text、search、tel、url、email 或 password 时,此属性适用,否则将被忽略.

A regular expression that the control's value is checked against. The pattern must match the entire value, not just some subset. Use the title attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is text, search, tel, url, email, or password, otherwise it is ignored.

这篇关于HTML5 输入模式在输入类型=“数字"中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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