• Resolved Carlos

    (@carlos1518)


    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://www.ads-software.com/plugins/contact-form-7/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Validation’ is closed to new replies.