Is there a way to add more than one ControlToValidate
to my RegularExpressionValidator?
I have two textboxes for postcode and I want to add the same RegularExpressionValidator to bo开发者_JAVA百科th.
Currently I have one for each box but if they are both wrong it shows up two error messages but I only want the user to see one.
Here's my RegularExpressionValidator
<asp:RegularExpressionValidator CssClass="errorpopup" Display="Dynamic" ID="rvpPostCodeZone" validationgroup="tbEditEmailCorr" runat="server" ErrorMessage="<strong>Please enter a valid post code.</strong>" ControlToValidate="tbEditPostCodeZone" ValidationExpression="^[0-9a-zA-Z' ']{3,}$" SetFocusOnError="true" />
Thanks
You can use a CustomValidator
, and perform the regex match server-side (and also on the client-side as well if you want). In the validation function(s) for this validator, check both controls.
精彩评论