Validating date (12/31/2008 12:00:00 AM)  with regular expression validator

Posted on 2009-04-29
Last Modified: 2013-11-26
The tag below validate date with mm/dd/yy format but cold not validate date such as this 12/31/2008 12:00:00 AM. How can I modify the tag to validate date such as this 12/31/2008 12:00:00 AM
<asp:RegularExpressionValidator ID="RegularValidatorEndDate" runat="server" ControlToValidate="txtEndDate"

                        ErrorMessage="Enter a valid End Date (i.e. mm/dd/yy)" ValidationExpression="^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$"


Open in new window

Question by:Projack
    LVL 32

    Expert Comment

    by:Daniel Wilson
    Use a CompareValidator instead of a RegularExpresionValidator.  use the DataTypeCheck operator to require that it's a Date.

    That will work MUCH better!

    Author Comment

    I add no problem with date as I stated that this (mm/dd/yy worked without broblem The issue is how do I use the CompareValidator to validate 12/31/2008 12:00:00 AM format
    LVL 14

    Accepted Solution


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    746 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

    14 Experts available now in Live!

    Get 1:1 Help Now