up
This commit is contained in:
@@ -26,8 +26,15 @@ try {
|
||||
$telVal = trim($datos['telefono'] ?? '');
|
||||
if ($telVal !== '') {
|
||||
$telDigits = preg_replace('/[^0-9]/', '', $telVal);
|
||||
if (!preg_match('/^(57)?3\d{9}$/', $telDigits)) {
|
||||
jsonError('El celular debe comenzar por 3 y tener 10 dígitos. Ej: 3001234567.');
|
||||
// Número colombiano: 10 dígitos empezando en 3, o con prefijo 57
|
||||
$esColombia = preg_match('/^57/', $telDigits) || (strlen($telDigits) === 10 && $telDigits[0] === '3');
|
||||
if ($esColombia) {
|
||||
$sinPrefijo = preg_replace('/^57/', '', $telDigits);
|
||||
if (!preg_match('/^3\d{9}$/', $sinPrefijo)) {
|
||||
jsonError('El celular colombiano debe comenzar por 3 y tener 10 dígitos. Ej: 3001234567.');
|
||||
}
|
||||
} elseif (strlen($telDigits) < 6 || strlen($telDigits) > 15) {
|
||||
jsonError('El número telefónico no es válido (debe tener entre 6 y 15 dígitos).');
|
||||
}
|
||||
}
|
||||
$docVal = trim($datos['numero_documento'] ?? '');
|
||||
|
||||
Reference in New Issue
Block a user