S
Sharkie
I need a regular expression to evaluate a text input field. The
validation rules are:
1) only A-Z and 0-9 chars allowed,
2) only one alpha char allowed (at any position) - rest are digits,
3) total length must be between 9 and 12 chars,
a valid example would be "123A456789"
I can enforce the first two rules by using this:
/^\d*[A-Z]\d*$/
but not limit chars between 9 and 12. The following doesn't work:
/^(\d*[A-Z]\d*){9,12}$/
because of the asterisk which can be any numbers of chars. Since I
don't know where the alpha character
will be I'm having hard time limiting number of digits either before
or after it.
What's a good way to enforce above rules. This should ideally be one
reg exp.
validation rules are:
1) only A-Z and 0-9 chars allowed,
2) only one alpha char allowed (at any position) - rest are digits,
3) total length must be between 9 and 12 chars,
a valid example would be "123A456789"
I can enforce the first two rules by using this:
/^\d*[A-Z]\d*$/
but not limit chars between 9 and 12. The following doesn't work:
/^(\d*[A-Z]\d*){9,12}$/
because of the asterisk which can be any numbers of chars. Since I
don't know where the alpha character
will be I'm having hard time limiting number of digits either before
or after it.
What's a good way to enforce above rules. This should ideally be one
reg exp.