$('#registrazioneForm #cancella-evento:checkbox').change(function() { if ($(this).is(':checked')) { // $("#registrazioneForm :input:not(.notdisable):not(:submit)").prop("disabled", true); $("#registrazioneForm #Pulsante").hide(); $("#registrazioneForm .rimuovi-partecipante").hide(); $("#registrazioneForm :input:not(:checkbox):not(:submit)").prop("readonly", true); $("#registrazioneForm :input:checkbox:not(.notdisable)").prop("disabled", true); $('#registrazioneForm option:not(:selected)').attr('disabled', true); console.log($(this).val() + ' is now checked'); } else { // $('#registrazioneForm :input').attr('disabled', false); $("#registrazioneForm #Pulsante").show(); $("#registrazioneForm .rimuovi-partecipante").show(); $("#registrazioneForm :input").prop("readonly", false); $("#registrazioneForm :input:checkbox").prop("disabled", false); $('#registrazioneForm option:not(:selected)').attr('disabled', false); console.log($(this).val() + ' is now unchecked'); } }); if ($("#registrazioneForm").length > 0) { // needs for recaptacha ready grecaptcha.ready(function () { // do request for recaptcha token // response is promise with passed token $('#registrazioneForm').parsley().on('form:error', function () { swal({ title: "Errore", text: "Compila tutti i campi obbligatori", type: "error", showConfirmButton: true }); }).on('form:submit', function () { $('#registrazioneForm').find('input[type=submit]').prop('disabled', true); grecaptcha.execute('6LfQHo4fAAAAADwY0QxYlDvZxmsbrEB9JRr0ZgjP', {action: 'homepage'}) .then(function (token) { // add token to form document.getElementById('g-recaptcha-response').value = token; form = $('#registrazioneForm'); $.ajax({ url: "/eventi/assets/ajax/invia-mail.php", type: "POST", data: form.serialize(), success: function (data) { if (data.status == "success") { swal({ type: 'success', text: data.message, timer: 1500, showConfirmButton: false }) setTimeout(function () { window.location = 'https://www.festadellavita.info/conferma/' }, 1000); } else if (data.status == "error") { $('#registrazioneForm').find('input[type=submit]').prop('disabled', false); swal({ title: "Errore", text: data.message, type: "error", showConfirmButton: true }); return false; } }, }); }); return false; }); }); }