Click here to Skip to main content
15,884,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm using the dd/MM/yyyy format for the date entry and i need to Validate date month year with / separator i want to do that with compare validator..plz help me
Posted

If you just need to validate the format of the date then use a Regular Expression.

If you need to validate against a specific date then using a custom validator would be better since the date entered could be in different format, such as one or two digit month.
 
Share this answer
 
Refer this link

It has the excat solution you are asking for..

http://geekswithblogs.net/ptahiliani/archive/2009/07/04/how-to-use-compare-validator-with-ddmmyyyy-format-of-date.aspx

The converted code from vb to c#

C#
Protected Page_Load(object sender, System.EventArgs e) 
    {
        cmpStartDate.ValueToCompare =    System.DateTime.Now.ToShortDateString();
    }
    
Protected btnValidate_Click(object sender, System.EventArgs e) 
    {
        if (!Page.IsValid)
            Response.Write("Valid dates entered");
        
    }
 
Share this answer
 
v2
Comments
[no name] 24-May-12 9:53am    
i want this in vc#
Jim Jos 24-May-12 10:08am    
I have given a C# translation1!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900