Easy Tutorial
❮ Control Customvalidator Aspnet Intro ❯

ASP.NET RequiredFieldValidator Control


Definition and Usage

The RequiredFieldValidator control makes an input control a mandatory field.

With this control, validation fails if the initial value of the input has not changed. By default, the initial value is an empty string ("").

Note: Spaces at the beginning and end of the input value will be removed before validation.

Note: The InitialValue property does not set a default value for the input control. It indicates the value that you do not want the user to enter in the input control.


Properties

Property Description
BackColor The background color of the RequiredFieldValidator control.
ControlToValidate The ID of the control to validate.
Display The display behavior of the validation control. Legal values are: None - The control does not display. Used only for displaying error messages in the ValidationSummary control.<br> Static - The control displays an error message if validation fails. Space for the message is reserved on the page even if the input passes validation.<br> Dynamic - The control displays an error message if validation fails. Space for the message is not reserved on the page if the input passes validation.
EnableClientScript A 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 displayed in the ValidationSummary control when validation fails. Note: If the Text property is not set, this text is also displayed in the validation control.
ForeColor The foreground color of the control.
id The unique ID of the control.
InitialValue Specifies the initial value of the input control. The default is "".
IsValid A Boolean value that indicates whether the control specified by ControlToValidate passed validation.
runat Specifies that the control is a server control. Must be set to "server".
Text The message displayed when validation fails.

Example

RequiredFieldValidator


❮ Control Customvalidator Aspnet Intro ❯