This commit is contained in:
Lizandro Guarnizo
2026-04-18 13:10:47 -05:00
parent 79ce470168
commit 1b441461ad
2 changed files with 38 additions and 2 deletions
+15 -1
View File
@@ -1419,6 +1419,20 @@ const formVer = {
// ═══════════════════════════════════════════════════════
// agendaNueva — Agendar domicilio desde el portal enfermero
// ═══════════════════════════════════════════════════════
/**
* Normaliza un teléfono colombiano a 573XXXXXXXXX (sin +).
* - 10 dígitos empezando por 3 → antepone 57
* - +57XXXXXXXXXX → quita el +
* - Cualquier otro valor → solo dígitos
*/
function normalizarTelefono(val) {
let t = (val || '').replace(/[^0-9+]/g, '');
if (t.startsWith('+')) t = t.slice(1);
if (t.length === 10 && t.startsWith('3')) t = '57' + t;
return t || null;
}
const agendaNueva = {
_modal: null,
_buscarTimer: null,
@@ -1667,7 +1681,7 @@ const agendaNueva = {
tipo_documento: document.getElementById('na-np-tipo-doc').value,
numero_documento: documento,
eps: document.getElementById('na-np-eps').value.trim() || null,
telefono: document.getElementById('na-np-telefono').value.trim() || null,
telefono: normalizarTelefono(document.getElementById('na-np-telefono').value),
fecha_nacimiento: document.getElementById('na-np-fnac').value || null,
email: document.getElementById('na-np-email').value.trim() || null,
}),