Validation in asp.net

Can I assign two validators to a text field? I used the regularexpression validator and the required identifier for the txtAccount text field, but only regularexpressionvalidator works when executed. I used this code:

<asp:RegularExpressionValidator ID="REV1" runat="server" 
                        ErrorMessage="should be a numeric value" 
ValidationExpression="\d*" ControlToValidate="txtAccount">     
</asp:RegularExpressionValidator>

<asp:RequiredFieldValidator ID="RFV1" runat="server" 
ErrorMessage="AC.No already exists" ControlToValidate="txtAccount">   
</asp:RequiredFieldValidator>   
+5
source share
2 answers

Yes, you can assign two validators to one control; your problem is that your validators are kind of "mutually exclusive" and you think that only one of them shoots.

, , , , , "-" ; , "-" , , "-" . , , " -", , , , ! ?

, ValidationSummary.

+3

. - , . , , . , . , . .

+1

All Articles