ASP.NET RegularExpressionValidator Control
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
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 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
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:
|
| 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
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.
AI is thinking...
ASP.NET RequiredFieldValidator Control
Click to Share Notes
Write notes...
Image URL
Image description
Share Notes
- Nickname Nickname (required)
- Email Email (required)
- Reference URL Reference URL
YouTip