function infoAggiornate(e) { swal({ type: 'success', text: e, timer: 1500, showConfirmButton: false }) }; function toggleFields(select) { //form crea il tuo evento document.querySelector('#privato').classList.toggle('d-none', select.value != 'privato') document.querySelector('#ente').classList.toggle('d-none', select.value != 'ente') document.querySelector('#rest').classList.remove('d-none') document.querySelectorAll('#privato input').forEach(input=>select.value == 'privato' ? input.setAttribute('required', "required") : input.removeAttribute('required')) document.querySelectorAll('#ente input').forEach(input=>select.value == 'ente' ? input.setAttribute('required', "required") : input.removeAttribute('required')) } if ($("#contattiForm").length > 0) { // needs for recaptacha ready grecaptcha.ready(function () { // do request for recaptcha token // response is promise with passed token $('#contattiForm').parsley().on('form:error', function () { swal({ title: "AVVISO_ERRORE", text: "AVVISO_ERRORE_CAMPI_OBBLIGATORI", type: "error", showConfirmButton: true }); }).on('form:submit', function () { $('#contattiForm').find('button[type=submit]').prop('disabled', true); grecaptcha.execute('6LdYgJYcAAAAACUR13QWHpfK7FSjFWRMTbJBi7NC', {action: 'homepage'}) .then(function (token) { // add token to form document.getElementById('g-recaptcha-response').value = token; form = $('#contattiForm'); $.ajax({ url: "https://www.powerups.it/assets/ajax/invia-mail.php", type: "POST", data: form.serialize(), success: function (data) { if (data.status == "success") { infoAggiornate(data.message); setTimeout(function () { window.location = 'https://www.powerups.it' }, 2000); } else if (data.status == "error") { $('#contattiForm').find('button[type=submit]').prop('disabled', false); swal({ title: "Errore", text: data.message, type: "error", showConfirmButton: true }); return false; } else { $('#contattiForm').find('button[type=submit]').prop('disabled', false); } }, }); }); return false; }); }); } $(window).on("load", function() { eqbox(".js-eqbox", 767) }); function eqbox(classe, breakpoint) { if($(classe).length && $(window).width()>breakpoint) { e=0; $(classe).each(function() { $(this).height()>e&&(e=$(this).height()) } ), $(classe).height(e) } }