YouTip LogoYouTip

Control Regularexpvalidator

ASP.NET RegularExpressionValidator Control

ASP.NET RegularExpressionValidator Control

ASP.NET Tutorial

ASP.NET TutorialASP.NET Introduction

WP Tutorial

WebPages IntroductionWebPages RazorWebPages LayoutWebPages FoldersWebPages GlobalWebPages FormsWebPages ObjectsWebPages FilesWebPages HelpersWebPages WebGridWebPages ChartsWebPages EmailWebPages PHPWebPages PublishWebPages Examples

WP Reference Manual

WebPages ClassesWebPages SecurityWebPages DatabaseWebPages WebMailWebPages Helpers

ASP.NET Razor

Razor IntroductionRazor SyntaxRazor C# VariablesRazor C# LoopsRazor C# LogicRazor VB VariablesRazor VB LoopsRazor VB Logic

ASP.NET MVC

MVC IntroductionMVC ApplicationMVC FoldersMVC LayoutMVC ControllersMVC ViewsMVC DatabaseMVC ModelsMVC SecurityMVC HTML HelpersMVC PublishMVC Reference Manual

WF Tutorial

WebForms IntroductionWebForms PagesWebForms ControlsWebForms EventsWebForms FormsWebForms ViewStateWebForms TextBoxWebForms ButtonWebForms Data BindingWebForms ArrayListWebForms HashtableWebForms SortedListWebForms XML FilesWebForms RepeaterWebForms DataListWebForms Database ConnectionWebForms Master PagesWebForms NavigationWebForms Examples

WF Reference Manual

WebForms HTMLWebForms ControlsWebForms Validation

ASP.NET Web Server Controls

ASP.NET RequiredFieldValidator Control

Explore Further

Computer Science

Web Services

Software

Web Design & Development

Programming Languages

Programming

Scripting Languages

Development Tools

Scripting

Web Service

ASP.NET RegularExpressionValidator Control


Image 3: Validation Server Controls Validation Server Controls


Definition and Usage

The RegularExpressionValidator control is used to validate whether an input value matches a specified pattern.

Note: Unless the browser does not support client-side validation or the EnableClientScript property is set to false, both server-side and client-side validation will be performed.

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


Properties

Property Description
BackColor Background color of the RegularExpressionValidator control.
ControlToValidate The id of the control to validate.
Display The display behavior of the validation control. Valid values are:
  • None - The control is not displayed. Used only to display error messages in the ValidationSummary control.
  • Static - If validation fails, the control displays the error message. Even if input passes validation, space is reserved on the page to display the message, meaning the space for the message is pre-allocated.
  • Dynamic - If validation fails, the control displays the error message. If input passes validation, no space is reserved on the page to display the message, meaning the space for the message is added dynamically.
EnableClientScript Boolean value that specifies whether to enable client-side validation.
Enabled Boolean value that specifies whether to enable the validation control.
ErrorMessage The text displayed in the ValidationSummary control when validation fails.
Note: If the Text property is not set, the text will also be displayed in the validation control.
ForeColor Foreground color of the control.
id The unique id of the control.
IsValid Boolean value indicating whether the control specified by ControlToValidate has passed validation.
runat Specifies that this control is a server control. Must be set to "server".
BackColor Background color of the RegularExpressionValidator control.
Text The message displayed when validation fails.
ValidationExpression Specifies the regular expression to validate the input control. The syntax of the expression differs between client-side and server-side. JScript is used for client-side. On the server side, it uses the language you specify.

Examples

RegularExpressionValidator

In this example, we declared a TextBox control, a Button control, a Label control, and a RegularExpressionValidator control in the .aspx file. The submit() function checks if the page is valid. If it is valid, it returns "The page is valid!" in the Label control. If it is not valid, it returns "The page is not valid!" in the Label control. If validation fails, the text "The zip code must be 5 numeric digits!" will be displayed in the RegularExpressionValidator control.


Image 4: Validation Server Controls Validation Server Controls

AI is thinking...

ASP.NET Web Server Controls

ASP.NET RequiredFieldValidator Control

iFlytek Xingchen Coding Plan includes free model call quotas for DeepSeek, GLM, Kimi, MiniMax. One-stop experience and deployment platform. Configuration Guide Β₯3.9/ month Activate Now

Click to Share Notes

Cancel

Write notes...

Image URL

Image description

Image size Γ—

Share Notes

  • Nickname Nickname (required)
  • Email Email (required)
  • Reference URL Reference URL

Category Navigation

← Ng Ng CloakNg Ng Cloak β†’