I was looking for exactly this and earned from me in another way. Make two fields as shown below in the contact form field-7.
[email* email placeholder "Email"] [email* email-confirm placeholder "Confirm Email"]
Copy / Paste the following PHP code into the functions.php file
function register_scripts() { if ( !is_admin() ) { // include your script wp_enqueue_script( 'email-confirm', get_bloginfo( 'template_url' ) . '/js/email-confirm.js' ); } } add_action( 'wp_enqueue_scripts', 'register_scripts' );
Be sure to change the path to the file so that it matches and loads the js file with the code below into this path directory.
// First we trigger the form submit event jQuery( document ).ready( function () { jQuery('.wpcf7-submit').click(function () { // We remove the error to avoid duplicate errors jQuery('.error').remove(); // We create a variable to store our error message var errorMsg = jQuery('<span class="error">Your emails do not match.</span>'); // Then we check our values to see if they match // If they do not match we display the error and we do not allow form to submit if (jQuery('.email').find('input').val() !== jQuery('.email-confirm').find('input').val()) { errorMsg.insertAfter(jQuery('.email-confirm').find('input')); return false; } else { // If they do match we remove the error and we submit the form jQuery('.error').remove(); return true; } }); } );
I used it on my website and worked great. Hope this helps someone like me.
Link: Contact Form 7 Verify Email Address
source share