| Introduction
Here we have to discuss the Regular expression ie going to validate date on different way ie: different date format
Technologies:
ASP.NET
Language:
C# and VB.NET
Prerequisite
.NET Framework 2.0 Visual Studio 2005
Implementation Code
It depends on which is the format you want to use. For a date format like: yyyy-mm-dd you could write it like: (19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01]) HTML CODE hi, so what is the valid input? anyway, you can do something like this {codecitation class="brush: csharp; gutter: true;" width="650px"} "TextBox6" runat="server"> "RegularExpressionValidator2" runat="server" ControlToValidate="TextBox6" ErrorMessage="RegularExpressionValidator" ValidationExpression="(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])"> Invalid Date Format: (yyyy-mm-dd)
{/codecitation} Here i am going to give different format of date expression you can change only the validationExpression ^((0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](?:19|20)\d\d)$ -- Invalid Date Format: (dd-mm-yyyy)
You can use dd MM yyyy HH:mm:ss with this expression: (0[1-9]|[12][0-9]|3[01])\s(0[1-9]|1[012])\s(19|20)\d\d\s([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]) To use the moth in the MMM format you would have to provide each moth as an option in the expression. Here is one example for January, February and March (0[1-9]|[12][0-9]|3[01])\s(jan|fev|mar|etc)\s(19|20)\d\d\s([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]) Thank you Venkat
|