Author |
Topic |
susan_151615
Yak Posting Veteran
99 Posts |
Posted - 2008-10-17 : 03:52:21
|
hi the u ser have to enter the date only in mm/dd/yyyy format for that i have written the validation control like this its not hellping me my coding is in vb.net can anyone help me in sorting this out <asp:regularexpressionvalidator id="regExpDate" runat="server" Display="Dynamic" EnableClientScript="False" ControlToValidate="txtSelect" ErrorMessage="It is not a valid date.Format is MMDDYY" ValidationExpression="^\d{2}[\/-]\d{2}[\/-]\d{2,4}$"></asp:regularexpressionvalidator></TD>susan |
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
|
susan_151615
Yak Posting Veteran
99 Posts |
Posted - 2008-10-20 : 04:40:33
|
no error is coming the validation is not working and i dono where i have gone wrongsusan |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-10-20 : 05:18:05
|
paste your code here |
|
|
susan_151615
Yak Posting Veteran
99 Posts |
Posted - 2008-10-20 : 05:28:26
|
<asp:regularexpressionvalidator id="regExpDate" runat="server" Display="Dynamic" EnableClientScript="False" ControlToValidate="txtSelect"ErrorMessage="It is not a valid date.Format is MMDDYY" ValidationExpression="^\d{2}[\/-]\d{2}[\/-]\d{2,4}$"></asp:regularexpressionvalidator>susan |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-10-20 : 05:50:40
|
Your code that has the control txtSelect and the variable that catchs and holds the postback values |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-10-20 : 09:05:45
|
Don't use a regular expression validator, you are re-inventing the wheel. You can use a Calendar Control to let the user pick a date from a calendar, or you can use a CompareValidator with Type="Date" and Operator="DataTypeCheck". - Jeffhttp://weblogs.sqlteam.com/JeffS |
|
|
susan_151615
Yak Posting Veteran
99 Posts |
Posted - 2008-10-21 : 00:31:56
|
ok thank u smith i will try it out and check out and saysusan |
|
|
Ohmslaw
Starting Member
11 Posts |
Posted - 2008-11-13 : 10:42:02
|
This is the validation expression I use for short dates:\d{1,2}[/-]\d{1,2}[/-]((\d{4})|(\d{2}))I use ((\d{4})|(\d{2})) to allow 4 or 2 numbers /d{2,4} will allow 2-4. I also found I had to use the greater number first when using | {or} later in the expression or it will fail.Ohms... |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
Ohmslaw
Starting Member
11 Posts |
Posted - 2008-11-13 : 12:01:07
|
This control is only to validate syntax, but this expression can cut down on bad dates.(([1][012])|([123456789]))[-/](([0123]\d{1})|(\d{1}))[-/](([123]\d{3})|(\d{2}))You will have to validate Date through Datetime object as you posted to verify accual date.Ohms... |
|
|
|