Introduction
This article explains how to solve two common issues when working with forms:
- Prevent users from selecting a placeholder option in dropdown fields.
- Remove the “* indicates required fields” message above some forms.
Disable Placeholder Options in Select Fields
When a placeholder is added to a dropdown field (via the “Placeholder” setting in the field’s appearance options), it appears correctly but remains selectable. This can lead to users submitting the form without making a real selection.

To prevent this, use the following code:
// Disable placeholder in dropdown choices so it can't be selected
add_filter( 'gform_field_content', function ( $content, $field, $value, $lead_id, $form_id ) {
if ( $field instanceof GF_Field_Select && $field->placeholder ) {
// Add 'disabled' and 'selected' attributes to the placeholder option
$content = preg_replace(
'/<option\s+class=[\'"]gf_placeholder[\'"]/',
'<option class="gf_placeholder" disabled selected',
$content
);
}
return $content;
}, 10, 5 );

This filter:
- Detects dropdown fields that use a placeholder.
- Finds the empty-value <option> element.
- Adds disabled and selected attributes to make it visible but unselectable.
Remove the “* Indicates Required Fields” Message
By default, some forms show a message like:
“* indicates required fields”
This message appears even if the title and description are disabled.
To remove it, add the following code:
add_filter( 'gform_required_legend', '__return_empty_string' );
Refer to this article for more information about the gform_required_legend and gform_field_content for further details on usage and options.
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?