I have to try to write a pattern that accepts a character in the form of S0000/0000/0000 or P0000/0000/0000 Where 0 is any number
This is what I have a try
<input class="form-control" type="text" pattern="^\d{5}/\d{4}/\d{4}$" name="index_no" required>
But that pattern it only accepts 5 digits / 4 digits / 4 digits what I need is S0000/0000/0000 OR P0000/0000/0000
Use \ to escape special characters in html.
Try this,
pattern="[SP]\d{4}\/\d{4}\/\d{4}"
You can test for correctness of regex expressions in this tester site
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With