//contact us form var contactSending = false; // candado anti doble envío $(".contact_btn").on('click', function() { // si ya hay un envío en curso, ignorar clicks adicionales if (contactSending) return; $(".contact_btn i").removeClass('d-none'); //simple validation at client's end var output; var proceed = "true"; var str = $('#contact-form-data').serializeArray(); $('#contact-form-data input').each(function() { if (!$(this).val()) { proceed = "false"; } }); $('#contact-form-data textarea').each(function() { if (!$(this).val()) { proceed = "false"; } }); //everything looks good! proceed... if (proceed === "true") { var accessURL = "https://b8gq8a89ac.execute-api.us-east-1.amazonaws.com/default/sendContactEmail"; //data to be sent to server const body = JSON.stringify({ senderName: str[0].value, senderEmail: str[1].value, senderPhone: str[2].value, message: str[3].value }); const requestOptions = { method: "POST", body }; // activar candado y deshabilitar el botón mientras se envía contactSending = true; $(".contact_btn").addClass('disabled').css('pointer-events', 'none'); fetch(accessURL, requestOptions) .then((response) => { if (!response.ok) throw new Error("Error in fetch"); return response.json(); }) .then((response) => { document.getElementById("result-text").innerText = "Correo enviado exitosamente"; document.getElementById("contact-form-data").reset(); $("#result").hide().html('').slideDown(); }) .catch((error) => { document.getElementById("result-text").innerText = "Ha ocurrido un error"; }) .finally(() => { // liberar el candado y reactivar el botón contactSending = false; $(".contact_btn i").addClass('d-none'); $(".contact_btn").removeClass('disabled').css('pointer-events', ''); }); } else { output = '