I'm trying to make a custom pattern for my html input but have no idea how to do so!
The pattern I want: 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}"
.
Try inputting an invalid value, and hit submit. The browser will give an error with the message from title
property.
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.