Solved

Field validator expression.

Posted on 2007-03-27
1
208 Views
Last Modified: 2010-04-16
Required field validator. YYYYMM

Numbers only has to be a period.
of type numeric for example 200701


0
Comment
Question by:mathieu_cupryk
1 Comment
 
LVL 35

Accepted Solution

by:
mrichmon earned 500 total points
ID: 18803278
<asp:requiredfieldvalidator runat="server" controltovalidate="yourfield" errormessage="Please enter this value in the format YYYYMM" display="dynamic" />
<asp:regularexpressionvalidator runat="server" controltovalidate="yourfield"  validationexpression="[0-9]{6}" errormessage="Please enter this value in the format YYYYMM" display="dynamic" />

But that does allow 000701

If you want to restrict the years you need a more complex validation expression like:

[1-2][0-9]{3}(0[1-9]|11|12)

which makes the year start with a 1 or 2 followed by 3 digits and a valid month
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now