Spacer
s
menumenu
Spacer
Spacer
Login  |  Register search:  
Spacer
Spacer
Required Field Validator

The Required Field Validator is used to ensure that a user enters a value in a Textbox, or selects a value from one of the “List Item” fields.

The Field Control types which support the Required Field Validator are:

  • Textbox
  • Dropdown List
  • Listbox
  • RadioButton List
  • File Upload

The Required Field Validator has three attributes which can be modified when adding this Validator to a field:

  • Error CSS Class: This is the CSS class name applied to the Error Message when displayed in the Browser. The DotNetNuke® class name “NormalRed”, is used by default.
  • Error Message: This is the message to be displayed in the Browser when the user input fails validation.
  • Initial Value: The value entered here is used by the Required Field Validator to determine if the user supplied value is the same as the “Initial Value”, if so then validation fails.

Using the Required Field Validator with the different field types is explained below:


Adding a Required Field Validator to a Textbox or File Upload
Adding a Required Field Validator for a Textbox is straightforward, simply edit the field, click on “Add Validator” in the Validators Data Grid, modify the Error Messages, and click “Update”. The Error Message is shown in the Designer. 

Adding a Required Field Validator to a Dropdown List
Adding a Required Field Validator to a Dropdown List requires some planning, as mentioned in Adding a Dropdown List, adding a prompt as the first item in the List Items data grid like “<< Select >>” for the Text part and “0” for the Value part gives us “0” to use as the Initial Value. If a user does not make a selection, validation will fail.

Adding a Required Field Validator to a Listbox or RadioButton List
When an Initial Value is not used, adding a Required Field Validator to a Listbox or RadioButton list is the same as for the Textbox. When an Initial Value is used the steps are the same as for the Dropdown List.

This section will show how to require a user to agree to the Terms & Conditions in order to submit the form using a RadioButton List, but the steps would be the same for a Listbox. This section will also use a different form.

Required Field Validator Presentation

Spacer
SpacerfooterSpacer
Spacer
Update :: March 10, 2010
Spacer