Title: Validation select custom using wpcf7_add_shortcode
Last modified: August 30, 2016

---

# Validation select custom using wpcf7_add_shortcode

 *  [pauloestevaons](https://wordpress.org/support/users/pauloestevaons/)
 * (@pauloestevaons)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/validation-select-custom-using-wpcf7_add_shortcode/)
 * Hello,
    I need help to validate a select I created through wpcf7_add_shortcode.
 * When selected “notselect” I want to present an error message and do not send 
   the form.
 * I’ve tried everything! I thank anyone who can help me.
 * The code of my select:
 *     ```
       wpcf7_add_shortcode('eventos_lista', 'createbox', true);
       function createbox(){
       			$lista_produtos = new WP_Query(array('showposts'=>100, 'post_type' => 'eventos'));
       			$output = "<select name='evento' id='evento' class='form-control' onchange='document.getElementById(\"evento\").value=this.value;'><option value='notselect'>Evento</option>";
       			//foreach ( $myposts as $post ) : setup_postdata($post);
       			while ($lista_produtos->have_posts()) : $lista_produtos->the_post();
   
       				$data = rwmb_meta( 'paulo_date' );
       				$ativo = rwmb_meta( 'paulo_radio' );
       				$title = get_the_title();
       				if($ativo == 1) {
       					$output .= "<option value='$title'>$title - $data</option>";
       				}
   
       			endwhile;
       			$output .= "</select>";
       			return $output;
       }
       ```
   
 * thanks!
 * [https://wordpress.org/plugins/contact-form-7/](https://wordpress.org/plugins/contact-form-7/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/validation-select-custom-using-wpcf7_add_shortcode/#post-6396482)
 * See [Developer’s Cookbook: Custom Validation](http://contactform7.com/2015/03/28/custom-validation/)
 *  Thread Starter [pauloestevaons](https://wordpress.org/support/users/pauloestevaons/)
 * (@pauloestevaons)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/validation-select-custom-using-wpcf7_add_shortcode/#post-6396644)
 * Takayuki,
    I created the code below:
 *     ```
       add_filter( 'wpcf7_validate_eventos_lista*', 'custom_email_confirmation_validation_filter', 20, 2 );
       function custom_email_confirmation_validation_filter( $result, $tag ) {
           $tag = new WPCF7_Shortcode( $tag );
   
           if ( 'evento' == $tag->name ) {
               $evento = isset( $_POST['evento'] ) ? trim( $_POST['evento'] ) : '';
   
               if ( $evento == 'notselect') {
                   $result->invalidate( $tag, 'Selecione um evento acima.' ) );
               }
           }
           return $result;
       }
       ```
   
 * The filter is working, however it does not have the phrase “Please fill the required
   field.” under the select I created, similar to most inputs.
 * If you want to see running: [http://breventos.net/confirme-sua-presenca/](http://breventos.net/confirme-sua-presenca/)
 * thanks!
 *  Thread Starter [pauloestevaons](https://wordpress.org/support/users/pauloestevaons/)
 * (@pauloestevaons)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/validation-select-custom-using-wpcf7_add_shortcode/#post-6396698)
 * Please

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Validation select custom using wpcf7_add_shortcode’ is closed to new 
replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [pauloestevaons](https://wordpress.org/support/users/pauloestevaons/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/validation-select-custom-using-wpcf7_add_shortcode/#post-6396698)
 * Status: not resolved