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:ScriptManager>


<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"


    ControlExtender="MaskedEditExtender1"


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


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







About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal.

2 comments:

Unknown 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