up
This commit is contained in:
+12
-3
@@ -373,9 +373,18 @@ async function guardarPaciente() {
|
||||
if (tel.startsWith('+')) tel = tel.slice(1);
|
||||
if (tel.length === 10) tel = prefijo + tel;
|
||||
datos.telefono = tel || null;
|
||||
// Validar formato de celular
|
||||
if (datos.telefono && !/^(57)?3\d{9}$/.test(datos.telefono)) {
|
||||
mostrarToast('El celular debe comenzar por 3 y tener 10 dígitos. Ej: 3001234567.', 'danger'); return;
|
||||
// Validar formato: colombiano (57) exige iniciar en 3 con 10 dígitos; otros países solo longitud
|
||||
if (datos.telefono) {
|
||||
const digits = datos.telefono.replace(/[^0-9]/g, '');
|
||||
const esColombia = prefijo === '57';
|
||||
if (esColombia) {
|
||||
const sinPref = digits.replace(/^57/, '');
|
||||
if (!/^3\d{9}$/.test(sinPref)) {
|
||||
mostrarToast('El celular colombiano debe comenzar por 3 y tener 10 dígitos. Ej: 3001234567.', 'danger'); return;
|
||||
}
|
||||
} else if (digits.length < 6 || digits.length > 15) {
|
||||
mostrarToast('El número telefónico no es válido (entre 6 y 15 dígitos).', 'danger'); return;
|
||||
}
|
||||
}
|
||||
|
||||
const r = await fetch('api/lab/save_paciente.php', {
|
||||
|
||||
Reference in New Issue
Block a user