Thursday, 16 May 2013

Required Field Validation for DropDown fields

In the recent release, we have included a required field validation for DropDown fields. This feature has only been added for the DetailsView control.

Property NameAllowed ValuesDescription
IsRequiredTrue/FalseSet to True if you want the field to be a required   field
IsRequiredInitialValueStringThis property is used to specify the initial value   for the field and compare if the field value has changed.
** Only valid if IsRequired   = True


This  post will teach you how to :
  • Setup required field validation for dropdown field
  • Changing value for selected text
Setting up Required Field validation
Step 1 : Add a DetailsView with DropDown field

Step 2 : Set IsRequired field property to ‘True’

Result :

  • A validation message is displayed when the ‘Save’ button is clicked.

Changing value for selected value in dropdown field
Step 1 : Set IsRequiredInitialValue to ‘I need to change this’

Result :

  • Selected value will be ‘I need to change this’
  • A validation message is displayed if user does not select a different value


Step 2 : Set IsRequiredInitialValue  property as blank

Result

  • Selected value will be blank

Additional information
  1. You cannot change the validation message.
  2. You can use Custom Setting / Page Parameter / System Variable / SQL Query to specify IsRequiredInitialValue text.
  3. If IsRequiredInitialValue is populated, DefaultValue will be overridden