Accept dd/mm/yyyy date format in ASP.NET AJAX MaskedEditExtender

A simple way to use the dd/mm/yyyy date format in the ASP.NET AJAX MaskedEditExtender is to use a culturename in the extender that supports this format. Shown below is an example which accepts the date in dd/mm/yyyy format and also use a MaskedEditValidator for a date field. The CultureName used here is of Great Britain "en-GB"

<asp:ScriptManager ID="ScriptManager1" runat="server">


<asp:TextBox ID="txtDate" runat="server" ValidationGroup="DtVal"/>      

<cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server"

    CultureName="en-GB" TargetControlID="txtDate"

    Mask="99/99/9999" MaskType="Date" AcceptNegative="None"/> 

<cc1:MaskedEditValidator id="MaskedEditValidator1" runat="server"


    EmptyValueMessage="Please enter Date" InvalidValueMessage="Invalid Date"

    ControlToValidate="txtDate" ValidationGroup="DtVal" />  

Will you give this article a +1 ? Thanks in advance

About The Author

Suprotim Agarwal
Suprotim Agarwal, ASP.NET Architecture MVP (Microsoft Most Valuable Professional) works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He is the Editor of a Developer Magazine called DNC Magazine. He has also written two EBooks 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook

Follow him on twitter @suprotimagarwal


arpith said...

How to do the same with a calendar extender and masked edit extender.whenever i select the date from calendar ,it comes in MM/dd/yyyy format.But i want it in dd/MM/yyyy format.Please help.

Anonymous said...

I tried this but it not works for 01/01/0000 like date