Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Email confirmation for Wordpress Contact Form 7 plugin
// Put this file inside your theme in folder js (js/email-confirm.js)
// First we add a hook to the form submit event
jQuery( document ).ready( function () {
jQuery('.wpcf7-submit').click(function () {
// We remove the error to avoid duplicate errors
// 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()) {
return false;
} else {
// If they do match we remove the error and we submit the form
return true;
// Hook for double check of email addresses.
// Taken from:
// Make sure your contact forms include an `email` and `email-confirm` field.
function register_scripts() {
if ( !is_admin() ) {
// include your script
wp_enqueue_script( 'email-confirm', get_stylesheet_directory_uri() . '/js/email-confirm.js' );
add_action( 'wp_enqueue_scripts', 'register_scripts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.