• Resolved Delpierooo

    (@delpierooo)


    Hi.

    Having a problem with settings one of two fileds to be required.
    Our end user has to attach their CV as a file or write a short bio in textfield below. So at least one of this two is enough. This used to work with:

    add_filter( 'wpcf7_validate', 'wpq_validate' );
    
    function wpq_validate( $result ) {
    
        $form  = WPCF7_Submission::get_instance();
        $field1 = $form->get_posted_data('upload-file-920');
        $field2 = $form->get_posted_data('your-message');
    
        if(  empty($field1) && empty($field2) ) {
            $result->invalidate('upload-file-920', 'Fill at least one.' );
            $result->invalidate('your-message', 'Fill at least one.' );
        } 
    return $result; 
    }

    But now, this is not working anymore. If only one is given it does not let you through. Thoughts?

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘One of two fields required’ is closed to new replies.