Thursday, October 8, 2009

Most Important and everytime requiring regular expressions for validators

lots of regular validator:
ValidationExpression="^\d{6,6}$" -- limit only 6 numeric value
ValidationExpression="^\d{10,10}$" -- limit only 10 numeric value
ValidationExpression="^((\+)?(\d{2}))$" -- accept +91 or +01

ValidationExpression="^[a-zA-Z\s]{2,25}" -- accept alphabets small and big caps min 2 to 25 character and space
ValidationExpression="^[a-zA-Z0-9\s]{2,25}" -- accept alphanumeric small and big caps min 2 to 25 character

email
ValidationExpression="\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" -- email validation

for upload
ValidationExpression="^.+(.jpg|.gif|.jpeg|.png|.JPG|.PNG|GIF)$" -- accept only xyz.jpg or any file name as .xxx
for accepting first name
ValidationExpression="[A-Z a-z\.\ ]{2,24}" -- accept alhanumeric with . and space

Login ID
ValidationExpression="[1-9A-Za-z\.\\_\-\@]{2,30}" -- accept alhanumeric with symbol like . _ - @
with min 2 and max 30 character

Password:
ValidationExpression="[a-zA-Z0-9\,\-\=\\+\/\@\#\$\*\&\%\^]{6,30}" -- accept alhanumeric with symbol like . _ - @
and all symbols given in bracket

No comments:

Post a Comment