; var searchParams = new URLSearchParams(window.location.search) searchParams.has('unsubscribe') var unsubscribe = searchParams.get('unsubscribe') if( unsubscribe ) { $.get("./unsubscribe_service.php", { "unsubscribe" : unsubscribe }, function(data, status){ if( data == 'success') { let content = "

You were successfully unsubscribed from Compagnie du Bois Sauvage's press releases and news letters.

"; $('.content').html(content); } } ); } $('.cancel').click(function () { $('input[name=email]').val(""); }); $('.unsubscribe').click(function () { var email = $('input[name=email]').val(); var msgAlert = checkMail(); if (msgAlert != ''){ alert( msgAlert ); } else { $.post("./unsubscribe_service.php", { "email" : email }, function(data, status){ if( data == "invalid") { let msg = "Email address doesn't exist!"; alert(msg); } else { let content = "

Thank you for unsubscribing the Compagnie du Bois Sauvage press releases and news letters .

We've sent you a confirmation email.

Please check your email to confirm your unsubscription.

You will not be unsubscribed until you confirm your email.

"; $('.content').html(content); } }); } }); function checkMail (){ var email = $('input[name=email]').val(); var msgAlert = ''; if ( email == '' ) { msgAlert = ""; return msgAlert; } else { var validation = /\S+@\S+\.\S+/; var pass = validation.test(email); if( !pass ){ msgAlert = "Invalid E-mail address"; return msgAlert; } } return ''; }