输入字段字符序列

Input Field to follow and check for the following algorithm. Maximum 11 alpha-numeric characters:

  1. 1st to 4th characters => Alphabetic characters- no numbers and special characters.

  2. 5th characters => 0 (Just a single Zero)

  3. 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);
  1. ^ : Starts with
  2. [a-z] : Allows Alphabetic characters
  3. {4}: Matches 4 preceding characters
  4. 0 : Matches 0
  5. [a-z0-9]: Matches any characters from a-z and 0-9 in any sequence
  6. $: End of string
  7. i: Case insensitive match

You should use regex to do this.

/^[a-z]{4}0[\w]{6}$/

Demo: https://regex101.com/r/cK1sO4/1

To check value in case sensitive use this regex.

/^[a-zA-Z]{4}0[\w]{6}$/