I am setting a RegularExpressionValidator at runtime in my aspx control as per below
<asp:RegularExpressionValidator ID="revValue" runat="server" ControlToValidate="txtZipCode"
ValidationExpression='<%=this.SettingManager.GetSettingValue("ZipCodeValidationExpression")%>'
ErrorMessage="Invalid Zip Code." Display="Dynamic" />
On the page, if I enter an invalid zipcode I do get the message "Invalid Zip Code", however, if I then enter a valid zip code nothing happens and the message remains "Invalid Zip Code".
If I manually set the expression as per below
<asp:RegularExpressionValidator ID="revValue" runat="server" ControlToValidate="txtZipCode"
ValidationExpression="^(d{5}-d{4}|d{5}|d{9})$|^([a-zA-Z]d[a-zA-Z] d[a-zA-Z]d)$"
ErrorMessage="Invalid Zip Code." Display="Dynamic" />
It works fine. What am I missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…