开发者

Adding more controls to RegularExpressionValidator

开发者 https://www.devze.com 2023-01-27 02:39 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消