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