We have a text box, where the user can input date. The only valid date allowed is MM/dd/yyyy
. After going through all the trouble, I think MaskedEditExtender
is the best choice. But I have some problems using it. Following is my ASPX code,
<div>
Date: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:MaskedEditExtender ID="TextBox1_MaskedEditExtender" runat="server"
CultureAMPMPlaceholder="" CultureCurrencySymbolPlaceholder=""
CultureDateFormat="" CultureDatePlaceholder="" CultureDecimalPlaceholder=""
CultureThousandsPlaceholder="" CultureTimePlaceholder="" Enabled="True"
Mask="99/99/9999" MaskType="Date" TargetControlID="TextBox1">
</asp:MaskedEditExtender>
<asp:CalendarExtender ID="TextBox1_CalendarExtender" runat="server"
Enabled="True" TargetControlID="TextBox1" Format="MM/dd/yyyy">
</asp:CalendarExtender>
</div>
Here are my questions:
- After I added the
MaskedEditExtender
, when I pick up a date from calendar, it won't write to the text box. - When I type some date in the text box, it will become 01-01-2011, not 01/01/2011, which is what I want.
- Should I use
CompareValidator
orMaskedEditValidator
? Since I want to make sure the date like 02/29/2011 is not valid.