1

I am using a piece of code, from which I want to peek the selected date I am using this piece of code

<BDP:BasicDatePicker ID="Calendar1" runat="server" placeholder="DD-MM-YY"></BDP:BasicDatePicker>

and RequiredFieldValidator to check that the field is filled or not.

<asp:RequiredFieldValidator ControlToValidate="Calendar1" ID="RequiredFieldValidator3" runat="server" ErrorMessage="Must Input a date"></asp:RequiredFieldValidator>

Now I want to check if that date is well formatted or valid in format DD-MM-YY(10-Jun-2016)

1

1 Answer 1

1

Use a RegularExpressionValidator with an expression like:

<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ErrorMessage="Invalid date format. Valid dates are dd/mm/yyyy. " ControlToValidate="Calendar1" Display="None" EnableTheming="False" EnableViewState="False" SetFocusOnError="True" ValidationExpression="^(0?[1-9]|[12][0-9]|3[01])[\/](0?[1-9]|1[012])[\/]\d{4}$"></asp:RegularExpressionValidator>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.