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

  contact-form-7, javascript, redirect, wordpress

We fave a CF7 form http://prntscr.com/v3ijfm, http://prntscr.com/v3ilpi .
Website url : https://loyard.it/

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()
{
    ?>
<script>
document.addEventListener('wpcf7mailsent', function(event) {
    $('#PayMeth input[name="radio-809"]').change(
        function() {
            if (this.checked && this.value == 'Paga alla consegna') {
                location = 'https://www.google.md/';
            }
        });
}, false);
</script>

Any suggestions ? Thanks in advance !

Source: Ask Javascript Questions

LEAVE A COMMENT