简体   繁体   English

在输入的属性“模式”上使用星号是什么意思?

[英]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.

相关问题 当 label 在输入字段中与星号一起使用时,当它的文本很大时,它会覆盖在星号上 - When label is used with asterisk in input field, when it's text is large it's over laying on Asterisk 在HTML中,在输入标签中使用&#39;step&#39;属性的目的是什么? - In html what's the purpose of using 'step' attribute in input tag? 在 div 中添加 target=&quot;_blank&quot; 属性是什么意思? - What's the meaning of adding a target="_blank" attribute in a div? 输入的pattern属性的正弦值是多少? - What's the sintax of the pattern attribute for inputs? 使用javascript触发输入框的模式属性? - Trigger the pattern attribute of input box using javascript? HTML 输入属性“模式”强制模式,即使是空白 - HTML input attribute “pattern” enforcing pattern even when blank 使用HTML 5和pattern属性时,如何将输入内容限制为仅英文字母? - How do I restrict my input to only the English alphabet when using HTML 5 and the pattern attribute? HTML 输入模式属性 - HTML input pattern attribute 电子邮件输入模式属性 - Email Input Pattern Attribute 在Django中,allow_blank和style = {&#39;base_template&#39;:&#39;textarea.html&#39;}作为CharField属性是什么意思? - In Django, what's the meaning of allow_blank and style = {'base_template' : 'textarea.html'} as CharField attribute?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM