Contact Form 7 Redirect on Submit and if the first radio is checked

  contact-form-7, javascript, redirect, wordpress

We fave a CF7 form, .
Website url :

The task:

If the first radio button is clicked and form is submitted, redirect the user to url.

For other 2 radio buttons a plugin handles the task (After successful payment user is redirtected).

I inserted the js in functions.php but it’s not working .

add_action('wp_footer', 'redirect_cf7');

function redirect_cf7()
document.addEventListener('wpcf7mailsent', function(event) {
    $('#PayMeth input[name="radio-809"]').change(
        function() {
            if (this.checked && this.value == 'Paga alla consegna') {
                location = '';
}, false);

Any suggestions ? Thanks in advance !

Source: Ask Javascript Questions