Reputation: 3117
I have the following validator control in my page.
<asp:CompareValidator ID="cvPatientDateOfBirth" runat="server"
ControlToValidate="txtPatientDateOfBirth"
ErrorMessage="Enter proper date.(DD/MM/YYYY)"
Font-Bold="True" Operator="GreaterThan" Display="Dynamic"
ValidationGroup="FirstPreview" CssClass="validatorMsg"
SetFocusOnError="True" ValueToCompare="1/1/1100" Type="Date" >
</asp:CompareValidator>
If I use both compare validator for date type check and regular expression validator for years(4digit) check, then "12/02/198" is showing error message for both the validators.
Can anyone please tell me how to do that?
Thanks.
Upvotes: 0
Views: 8308
Reputation: 3117
This regular expression is working properly
^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$
Upvotes: 1
Reputation: 28970
You can use RegularExpressionValidator and set ValidationExpression
ValidationExpression = "\d{1,2}\/\d{1,2}/\d{4}"
Upvotes: 4