Input Field to follow and check for the following algorithm. Maximum 11 alpha-numeric characters:
1st to 4th characters => Alphabetic characters- no numbers and special characters.
5th characters => 0 (Just a single Zero)
6th to 11th Characters => Alpha-numeric.
I think my question is quite simple, i want to enter 11 characters in an input field but first 4 characters should be as defined in point 1 and 5th character should be 0 and 6th characters to onward alphanumeric . input field should allow to enter characters as i defined , if some one want to enter 1 or other character at 5ht positions input field should not allow because 5ht position is for 0 and same expressions for other positions.
Looks like you have to use regex:
$('input').val().match(/^[a-z]{4}0[a-z0-9]{6}$/i);
^ : Starts with[a-z] : Allows Alphabetic characters{4}: Matches 4 preceding characters0 : Matches 0[a-z0-9]: Matches any characters from a-z and 0-9 in any sequence$: End of stringi: Case insensitive matchIf 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