这是我面临“无效日期”问题的代码:
我尝试使用日历控件选择
mm/dd/yyyy
格式的日期,并使用正则表达式验证该控件。但它显示“无效日期”错误消息。
这是代码:
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtInvoiceDate"
ValidationExpression="(0[1-9]|1[012])[/](0[1-9]|[12][0-9]|3[01])[/]\d{4}"
ErrorMessage="Invalid format Valid format is MM/dd/yyyy" ForeColor="Red"
Display="Dynamic" ValidationGroup="Submit" />
<asp:RequiredFieldValidator ID="rfvInvoiceDate" runat="server" ErrorMessage="Enter Invoice of Date"
Text="*" ControlToValidate="txtInvoiceDate" ValidationGroup="Submit"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="rfvInvoiceDateS" runat="server" ErrorMessage="Enter Invoice of Date"
Text="*" ControlToValidate="txtInvoiceDate" ValidationGroup="Confirm"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="rv_txtInvoiceDate" runat="server" ControlToValidate="txtInvoiceDate" ErrorMessage="Invalid Date"
Type="Date" MinimumValue="01/01/1990" MaximumValue="01/01/2090" ForeColor="Red" Display="Dynamic"
ValidationGroup="Confirm"> </asp:RangeValidator>
</ItemTemplate>