i am trying to set, if input field can have 8 digits and one letter at the end, Example: 25639154R
My code:
<form>
<input type="text" class="form-control" id="paycheck" />
<input type="submit" />
</form>
$( "input" ).attr("pattern", '^[A-z]{1}||^[0-9]{8}').prop('required', true)
it's working for any 8 numbers only.
Try
$( "input" ).attr("pattern", '^[0-9]{8}[A-Z]$').prop('required', true)
This will require the last character to be uppercase. You can add az
inside the character group to allow for case insensitive characters too.
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.