Ficha de invitados: teléfono móvil obligatorio y aviso de envío por correo electrónico
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TSyR5Zw5eGj6oPTRVjvP1b
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
6c3a572cdd
commit
a25c7c256e
+4
-2
@@ -24,6 +24,8 @@
|
||||
var el = els[j], bad = el.type === 'checkbox' ? !el.checked : !el.value.trim();
|
||||
if (bad) { el.focus(); say(el.type === 'checkbox' ? 'Marca las dos casillas finales para poder enviar la ficha.' : 'Faltan respuestas obligatorias (las marcadas con *).', false); return false; }
|
||||
}
|
||||
var t = s.querySelector('input[type=tel]');
|
||||
if (t && !/^\+?[\d ().-]{7,20}$/.test(t.value.trim())) { t.focus(); say('El teléfono no parece válido.', false); return false; }
|
||||
var m = s.querySelector('input[type=email]');
|
||||
if (m && !okMail(m.value.trim())) { m.focus(); say('El correo no parece válido.', false); return false; }
|
||||
return true;
|
||||
@@ -47,7 +49,7 @@
|
||||
var d = new Date(j.cita * 1000), o = { timeZone: 'Europe/Madrid' };
|
||||
var dia = d.toLocaleDateString('es-ES', Object.assign({ weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' }, o)).replace(',', '');
|
||||
var hora = d.toLocaleTimeString('es-ES', Object.assign({ hour: '2-digit', minute: '2-digit' }, o));
|
||||
cita.textContent = '📅 Recuerda que grabamos el ' + dia + ' a las ' + hora + ', y te enviaremos por correo la dirección del estudio.';
|
||||
cita.textContent = '📅 Recuerda que grabamos el ' + dia + ' a las ' + hora + ', y te enviaremos por correo electrónico la dirección del estudio.';
|
||||
hola.hidden = false; cita.hidden = false; intro.hidden = false; f.hidden = false;
|
||||
try { var s = JSON.parse(store('get') || '{}'); Object.keys(s).forEach(function (nm) { if (f.elements[nm] && f.elements[nm].type !== 'checkbox') f.elements[nm].value = s[nm]; }); } catch (e) {}
|
||||
show(0);
|
||||
@@ -73,7 +75,7 @@
|
||||
Array.prototype.forEach.call(f.elements, function (el) { if (/^q\d+$/.test(el.name)) resp[el.name] = el.value.trim(); });
|
||||
busy = true; say('Enviando…', true);
|
||||
fetch('/api/invitados', { method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ n: n, f: fe, email: f.email.value.trim(), resp: resp, consent: true, web: f.web.value || '', t: Date.now() - t0 }) })
|
||||
body: JSON.stringify({ n: n, f: fe, email: f.email.value.trim(), tel: f.tel.value.trim(), resp: resp, consent: true, web: f.web.value || '', t: Date.now() - t0 }) })
|
||||
.then(function (r) { return r.json().catch(function () { return {}; }).then(function (j) { return { ok: r.ok && j.ok, j: j }; }); })
|
||||
.then(function (x) {
|
||||
if (x.ok) { store('del'); f.reset(); steps.forEach(function (s) { s.hidden = true; }); paso.hidden = true; f.querySelector('.note:last-of-type').hidden = true; say(f.getAttribute('data-ok'), true); }
|
||||
|
||||
Reference in New Issue
Block a user