Viewing 5 replies - 1 through 5 (of 5 total)
  • Jainil Nagar

    (@jainilnagar)

    Hello @mattiamomy,

    Please add your form and code.

    Thread Starter mattiamomy

    (@mattiamomy)

    Form Code:

    [text* your-name  placeholder "Nome e Cognome"][tel* tel-266 placeholder "Numero di telefono"][email* your-email  placeholder "Indirizzo Email"][email* your-email-confirm placeholder "Conferma Indirizzo Email"][text your-subject  placeholder "Oggetto"]<strong>Il tuo messaggio</strong>[textarea your-message]
    
    [submit "Invia"]

    Function code:

    add_filter( 'wpcf7_validate_email*', 'custom_email_confirmation_validation_filter', 20, 2 );
      
    function custom_email_confirmation_validation_filter( $result, $tag ) {
      if ( 'your-email-confirm' == $tag->name ) {
        $your_email = isset( $_POST['your-email'] ) ? trim( $_POST['your-email'] ) : '';
        $your_email_confirm = isset( $_POST['your-email-confirm'] ) ? trim( $_POST['your-email-confirm'] ) : '';
      
        if ( $your_email != $your_email_confirm ) {
          $result->invalidate( $tag, "Are you sure this is the correct address?" );
        }
      }
      
      return $result;
    }
    Jainil Nagar

    (@jainilnagar)

    Hello @mattiamomy,

    Your code is correct and it should work properly.

    Is the form submitted without showing error?

    Also, Is there any JS error showing in the console window of the browser?

    Thread Starter mattiamomy

    (@mattiamomy)

    Hi @jainilnagar,

    no JS errors and the form is submitted properly with two different email on the fields.

    Now i’m using a child theme… i will try to put the code in the parent theme

    Thread Starter mattiamomy

    (@mattiamomy)

    Now it works… probabbly some conflict with other functions. I’ve moved the function in another place of the function.php and now works

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Two Fielnd valdation’ is closed to new replies.