imgrv
imgrv

Reputation: 121

Validate Form Input using pattern match in html5 form

how to do validate form with input pattern . i have looked into w3schools pattern attribute but not able to get how to implement it in my way. i want to match my form input in this way. this is the appid = "EVISA2505550816" . this pattern should match in input field. where in every id IVISA is common then next 10 digits will be.

<form method="post" action="#">
<input type="text" id="appid" name="appid" pattern="" required>
<input type="submit" name="submit">
</form>

Upvotes: 0

Views: 75

Answers (1)

Simon Loir
Simon Loir

Reputation: 106

You only have to write a regular expression in the pattern attribute : \d means that you want a digit and {10} means that you want that char 10 times.

Note that if the first letter is not always E, you can write [A-Z]VISA\d{10}

<form method="post" action="#">
<input type="text" id="appid" name="appid" pattern="EVISA\d{10}" required>
<input type="submit" name="submit">
</form>

Upvotes: 1

Related Questions