How can I make a drop down list required while not providing a pre-selected default value?

Issue

When adding a drop-down list control to a web form and making it required using WorkflowGen’s FORM_FIELDS_REQUIRED parameter, one of the items in the list will become the pre-selected default value, which may defeat the purpose of the required setting (often we want to force the end-user to select a value, not just assume that a pre-selected default is valid).

For example, in making a list named DropDownListCities required where the list includes only the elements New York, Montreal, and Paris, one of these items will become the default value and therefore submitting the form will pick this value (one of the cities), bypassing the need to force the user to think about the selection.

Solution

Add a list item (as the selected default) with the text Please select and the value containing one space only. WorkflowGen will detect this as an empty value, so submitting the form with this value will trigger the standard required field alert message, without programming. This will provide a true required field effect with a drop-down list without a default value pre-selected.

If the DropDownList control is bound to a database query, a simple tip to add an empty default value without programming is to alter your SQL query by prefixing it with the statement:

SELECT 'Please select',' '  
 UNION ALL  
 [...your SQL SELECT statement here...]

This will insert a blank default value at the top of the drop down list.