[select my_select class:input class:styled "Select Options"
"Option 1" "Option 2" "Option 3" "Option 4"]
Question:
How to prevent printing 'Select Options'
if user not selected any options in receiving email?
If user select first option ('Select Options')
,it should not print as 'Select Options'
in mail.
To do this, add default:{source} option to the form-tag from which you want to derive the default value. Available data sources are: get (HTTP GET variables), post (HTTP POST variables), and post_meta (custom fields). Logged-in user information is also available.
More recent versions of Contact Form 7 allow the use of first_as_label to create placeholder text that does not validate as an entry if users do not make a selection. Simply make your placeholder text be the first label in the list of options. wow. It works.
Change your select tag to the following
[select my_select class:input class:styled include_blank "Option 1" "Option 2" "Option 3" "Option 4"]
The first option will have "---" as the text and a blank value, <option value="">---</option>
If you want to replace the text "---" with "Select Options" add the following code to functions.php
function my_wpcf7_form_elements($html) {
$text = 'Select Option';
$html = str_replace('---', $text , $html);
return $html;
}
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With