ASP. NET validation Control RegularExpressionValidator

Source: Internet
Author: User

Definition and usage

The RegularExpressionValidator control is used to verify that the input values match the specified pattern.

Note: Both server side and client authentication are performed unless the browser does not support client authentication or the EnableClientScript property is set to False.

Note: If the input control is empty, validation will fail. Please use the RequiredFieldValidator control to make the field mandatory (required).

Property
Properties Description
BackColor The background color of the RegularExpressionValidator control.
ControlToValidate The ID of the control to validate.
Display Validates the display behavior of the control. Valid values are:
  • None-The control is not displayed. The error message is displayed only for the ValidationSummary control.
  • Static-If validation fails, the control displays an error message. Even if the input passes validation, the space on the page to display the message is reserved, that is, the space used to display the message is pre-allocated.
  • Dynamic-If validation fails, the control displays an error message. If the input is verified, the space on the page to display the message is not reserved, that is, the space used to display the message is dynamically added.
EnableClientScript Boolean value that specifies whether client-side validation is enabled.
Enabled A Boolean value that specifies whether the validation control is enabled.
ErrorMessage The text that is displayed in the ValidationSummary control when validation fails. Note: text is also displayed in the validation control if you do not set the Text property.
ForeColor The foreground color of the control.
Id The unique ID of the control.
IsValid A Boolean value that indicates whether the control specified by ControlToValidate passes validation.
Runat Specifies that the control is a server control. Must be set to "server".
BackColor The background color of the RegularExpressionValidator control.
Text The message that is displayed when validation fails.
ValidationExpression Specifies the regular expression that validates the input control. On both the client and the server, the syntax of the expression is different. JScript is used for clients. On the server, in accordance with the language you specify.

1<form id="Form1"runat="Server">2<div>3     4Input Character<asp:textbox id="TextBox1"runat="Server"></asp:TextBox>5<asp:regularexpressionvalidator id="RegularExpressionValidator1"runat="Server" 6Controltovalidate="TextBox1"Errormessage="4-6 characters"Forecolor="Red" 7validationexpression="\w{4,6}"></asp:RegularExpressionValidator>8<br/>9<asp:button id="BTN1"runat="Server"text="Submit"/>Ten      One</div> A</form>
View Code

ASP. NET validation Control RegularExpressionValidator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.