0

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>

1 Answer 1

1

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>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.