Available for Hire

Contact form 7 – Javascript API

Contact Form 7 emits a number of Javascript events that bubble up to the document object. In version 4.1 they can be found in contact-form-7/includes/js/scripts.js. If you’re using jQuery you can access those events like this:

$(document).on('spam.wpcf7', function () {
console.log('submit.wpcf7 was triggered!');
});

$(document).on('invalid.wpcf7', function () {
console.log('invalid.wpcf7 was triggered!');
});

$(document).on('mailsent.wpcf7', function () {
console.log('mailsent.wpcf7 was triggered!');
});

$(document).on('mailfailed.wpcf7', function () {
console.log('mailfailed.wpcf7 was triggered!');
});