是否可以验证它是电话号码但不需要它?现在的方式如果我不输入数字,它将引发错误。我在某处读到您可以更改正则表达式来执行此操作,我尝试将正则表达式包含在 (?:...?)
<asp:TextBox runat="server" ID="tbCompanyFax" Width="99%" Text='<%# Eval("CompanyFax")%>'></asp:TextBox>
<ajaxTK:MaskedEditExtender runat="server" ID="maskCompanyFax" AutoComplete="false" TargetControlID="tbCompanyFax" Mask="(999)999-9999" ClearMaskOnLostFocus="false" />
<asp:RegularExpressionValidator ID="regCompanyFax" runat="server" ControlToValidate="tbCompanyFax" ErrorMessage="Invalid Fax number" ValidationExpression="(?:((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4})?" Display="None"></asp:RegularExpressionValidator>