I am trying get the following to valid to dd-MMM-yyyy.
The calendar extender passes this format to the text box but is never shown in the text box.
The validation message appears for a fraction of a second and then all you see is the mark again
__-___-____
Example code:
<ajaxToolkit:CalendarExtender runat="server" Format="dd-MMM-yyyy"
TargetControlID="DOB" />
<ajaxToolkit:MaskedEditValidator ID="DOBMaskedEditValidator"
EmptyValueBlurredText="DOB required" EmptyValueMessage="DOB required"
InvalidValueBlurredMessage="DOB invalid" InvalidValueMessage="DOB invalid"
runat="server" ControlExtender="DobMaskedEditExtender"
SetFocusOnError="true" Display="Dynamic" ControlToValidate="DOB"
IsValidEmpty="false" />
<ajaxToolkit:MaskedEditExtender ID="DobMaskedEditExtender" runat="server"
MaskType="Date" TargetControlID="DOB" Mask="99-LLL-9999" CultureName="en-GB"
ClearMaskOnLostFocus="false" />
I've been looking at various examples but can't seem to pin down what the issue is. Anyone got any ideas how we do this with a custom date format? Should I be using MaskType=Date with a custom date format?
Sorry guys was overlooking the obvious. I had missed out the ValidationExpression attribute. I think because I had specified the format in the MaskedEditExtender I though that would be used alongside the validator.
A lot of examples out where show a regular expression like below:
But I need this to work in multiple languages so have gone for a more basic one:
This is now working fine.
Fully working example: