简体   繁体   English

我如何为我的HTML输入制作特定的模式

[英]How do i make a specific pattern for my html input

I'm trying to make a custom pattern for my html input but have no idea how to do so! 我正在尝试为我的html输入创建自定义模式,但不知道该怎么做!

The pattern I want: ABC-A0-01 我想要的模式:ABC-A0-01

So basically the first part has uppercase alphabets only, second part has uppercase with numeric values, and the last part is numeric only and is separated by a '-' 因此,基本上第一部分只有大写字母,第二部分只有大写的数字值,最后一部分只有数字,并用“-”分隔

<input type="text" class="form-control txtsize" id="equi" placeholder="Insert equipment name e.g ABC-A0-12" data-ng-model="equipmentToAdd">

You could use the pattern attribute with a RegEx such as this: pattern="[AZ]{3}[-][AZ]{1}[0-9]{1}[-][0-9]{2}" . 您可以将pattern属性与RegEx一起使用,例如: pattern="[AZ]{3}[-][AZ]{1}[0-9]{1}[-][0-9]{2}"

Try inputting an invalid value, and hit submit. 尝试输入无效的值,然后点击提交。 The browser will give an error with the message from title property. 浏览器将显示来自title属性的消息错误。

 <form> <input type="text" class="form-control txtsize" id="equi" placeholder="Insert equipment name eg ABC-A0-12" data-ng-model="equipmentToAdd" pattern="[AZ]{3}[-][AZ]{1}[0-9]{1}[-][0-9]{2}" title="Insert equipment name eg ABC-A0-12"> <button type="submit">Submit</button> </form> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用HTML 5和pattern属性时,如何将输入内容限制为仅英文字母? - How do I restrict my input to only the English alphabet when using HTML 5 and the pattern attribute? 如何使特定的键盘输入更改页面上的形状属性? - How do I make a specific keyboard input change the properties of shapes on my page? 如何使我的网站的特定部分看起来像这样? (使用 HTML 和 CSS。) - How do I make a specific part of my website look like this? (Using HTML and CSS.) 如何使HTML和Java表单重定向到自身,以便用户可以输入其他项? - How do I make my HTML and java form redirect to itself so that the user can input another item? 如何使特定的输入触发某些东西? - How do I make a specific input trigger something? 如何使用创建HTML表单 <label><input></label> <label>和<span>?</span></label> - How do I make a HTML form using <label> <input> and <span>? 如何从 html 数字输入中创建数字变量? - How do I make a number variable from a html number input? 如何使选择器更具体? - How do I make my selectors more specific? 如何将我的输入字段设为黑色并将文本设为蓝色 - How Do I Make My Input Fields Black and Text to Blue 如何根据我的 html 输入创建一个 javascript if 语句? - How do I create a javascript if statement depending on my html input?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM