[英]What's the meaning of the asterisk when using on the attribute “pattern” of an input?
Here's an example: 这是一个例子:
<input title="Only numbers" pattern="[0-9]*" type="text" />
I would like to know what implies using *
in pattern="[0-9]*"
我想知道在pattern="[0-9]*"
使用*
含义
Thanks! 谢谢!
*
means 0 or more of the previous item, in this case digits 0-9. *
表示前一项的0或更多,在这种情况下为数字0-9。
This means the empty string will also be allowed as well as "0", "12" etc.. 这意味着也将允许使用空字符串以及“ 0”,“ 12”等。
Other quantifiers exist, like +
means 1 or more etc... 存在其他量词,例如+
表示1或更多,等等。
There are many tutorials out there, but you can't go wrong with Wikipedia 那里有很多教程,但是Wikipedia不会出错
In your case, I'd recommend using the built-in number type instead as the intent is clearer... 在您的情况下,建议您改用内置数字类型,因为意图更清晰...
<input title="Only numbers" type="number" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.