ValidationExpression

G

Guest

ValidationExpression="\d{2}/\d{2}/\d{4}" how can you make this work for date
exactly. Taking care of Feb for example?
 
B

bruce barker

try:

"^(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?
:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]
|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])
00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[
6-9]|[2-9]\d)?\d{2})$"


doesn't require leading zero, allows 2 digit years and a date seperator of
"." or "/" or "-". feel free to edit to your needs



-- bruce (sqlwork.com)





| ValidationExpression="\d{2}/\d{2}/\d{4}" how can you make this work for
date
| exactly. Taking care of Feb for example?
|
 
G

Guest

Hi Bruce..
What about if i want to validate an email like:-
(e-mail address removed)?
 
P

Peter Blum

<flame>I wish Microsoft would do a better job documenting the purpose of the
CompareValidator because this question appears regularly!</flame>

The CompareValidator validates the format of dates, integers, and currency.
It handles dates exactly the way you need. Just set its Operator to
DataTypeCheck and Type to the desired format.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top