Solved

Field validator expression.

Posted on 2007-03-27
1
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET - Why is accordion not working? 3 72
C# LINQ 5 43
C#:  Need to switch between timer loop and token driven loop 2 31
How do you think this website does searches? 5 34
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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