Title: Custom Validation
Last modified: August 22, 2016

---

# Custom Validation

 *  Resolved [Carlos](https://wordpress.org/support/users/carlos1518/)
 * (@carlos1518)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/custom-validation-3/)
 * I’m trying to create a custom validation but it’s not working this is my code:
 *     ```
       add_filter( 'wpcf7_validate_text', 'your_validation_filter_func', 10, 2 );
       add_filter( 'wpcf7_validate_text*', 'your_validation_filter_func', 10, 2 );
   
       function your_validation_filter_func( $result, $tag ) {
           $type = $tag['type'];
           $name = $tag['name'];
   
           if ( 'cedula' == $name ) {
               $the_value = $_POST[$name];
   
               if ( !preg_match("/^(V|E|J)-[0-9]+$/", $the_value) ) {;
                   $result['valid'] = false;
                   $result['reason'][$name] = "Error message here";
               }
           }
   
           return $result;
       }
       ```
   
 * Any ideas?
 * [https://wordpress.org/plugins/contact-form-7/](https://wordpress.org/plugins/contact-form-7/)

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

 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/custom-validation-3/#post-5782122)
 * See [http://contactform7.com/2015/01/06/contact-form-7-41-beta/](http://contactform7.com/2015/01/06/contact-form-7-41-beta/)
 *  Thread Starter [Carlos](https://wordpress.org/support/users/carlos1518/)
 * (@carlos1518)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/custom-validation-3/#post-5782159)
 * that fixed it, thank you!

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

The topic ‘Custom Validation’ 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/)

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [validation](https://wordpress.org/support/topic-tag/validation/)

 * 2 replies
 * 2 participants
 * Last reply from: [Carlos](https://wordpress.org/support/users/carlos1518/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/custom-validation-3/#post-5782159)
 * Status: resolved