I have the following code:
<body>
<form action="" method="post">
<div>
<label>First Name: <input type="text" name="firstname" value=" " pattern="[a-zA-Z ]+"></input> </label>
</div>
<div>
<label>Last Name: <input type="text" name="lastname" value="" pattern="[a-zA-Z ]+"> </input> </label>
</div>
<div>
<label>Voucher: <input type="text" name="voucher" value="" pattern="^[0-9]{5}+[-]+[0-9]{5}+[-]+[A-Z]{2}*"></input> </label>
</div>
<input type="submit" value="Submit"></input>
</form>
</body>
The above code is my code, first name and last name are all working, the problem is the voucher input does not check the pattern I wanted, it should look like "12345-67890-AB".
+because you are already saying you need 5 characters^at the beginning of the regex (nor$at the end). the pattern attribute of HTML forms implies that