Contact Form 7 drop down required field customize

function custom_wpcf7_form_elements($html) {
function cf7_replace_include_blank($name, $text, &$html) {
$matches = false;
preg_match(‘/<select name=”‘ . $name . ‘”[^>]*>(.*)<\/select>/iU’, $html, $matches);
if ($matches) {
$select = str_replace(‘<option value=””>—</option>’, ‘<option value=””>’ . $text . ‘</option>’, $matches[0]);
$html = preg_replace(‘/<select name=”‘ . $name . ‘”[^>]*>(.*)<\/select>/iU’, $select, $html);
}
}
cf7_replace_include_blank(‘menu-780’, ‘How many sets would you like?’, $html);
cf7_replace_include_blank(‘menu-781’, ‘Which of the awesome sets would you like?’, $html);
cf7_replace_include_blank(‘menu-782’, ‘How many days would you like to rent some awesome clubs?’, $html);
return $html;
}
add_filter(‘wpcf7_form_elements’, ‘custom_wpcf7_form_elements’);

Leave a Reply

Your email address will not be published.