regex - validation pattern in ValidationExpression of asp.net webform: required at least one digit -


so have validate pattern support lower , upper case character , must have at least 1 digit, must between range of 8 16.

so far have

validationexpression="(^[a-za-z0-9](?=.*\d){8,16})$" 

that seems not working, hint ?

i.e.

abcdef not work  abcdef12 work 

the problem:

(^[a-za-z0-9](?=.*\d){8,16})$

this looking match within string that:
- contains single item out of [a-za-z0-9]
- has look-ahead of .*\d, lookahead hapening8-16 times.

possible solutions:

put {8,16} on [a-za-z0-9] rather look-ahead, , move look-ahead front:

^(?=.*\d)[a-za-z0-9]{8,16}$ 

also, if wish have atleast 1 of each capital , lowercase letters, can this:

^((?=.*\d)(?=.*[a-z])(?=.*[a-z])[a-za-z0-9]{8,16})$ 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -