cambios en front validaciones
This commit is contained in:
@@ -157,6 +157,57 @@ $color2 = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
document.getElementById("formRegistro").addEventListener("submit", function(event) {
|
||||
const rfcInput = document.querySelector('input[name="rfc"]');
|
||||
const emailInput = document.querySelector('input[name="email"]');
|
||||
const phoneInput = document.querySelector('input[name="phone"]');
|
||||
|
||||
const rfc = rfcInput.value.toUpperCase();
|
||||
const email = emailInput.value.trim();
|
||||
const phone = phoneInput.value.trim();
|
||||
|
||||
// Validación RFC
|
||||
const rfcRegex = /^[A-ZÑ&]{3,4}\d{6}[A-Z0-9]{3}$/;
|
||||
if (!rfcRegex.test(rfc)) {
|
||||
alert("RFC inválido. Asegúrate de que siga el formato correcto.");
|
||||
rfcInput.focus();
|
||||
event.preventDefault();
|
||||
return;
|
||||
} else {
|
||||
rfcInput.value = rfc; // Convertir a mayúsculas
|
||||
}
|
||||
|
||||
// Validación correo - solo minúsculas y con cualquier dominio
|
||||
const correoRegex = /^[a-z0-9._+-]+@[a-z0-9.-]+\.[a-z]{2,}$/;
|
||||
if (!correoRegex.test(email)) {
|
||||
e.preventDefault(); // Detiene el envío del formulario
|
||||
alert("No es una dirección de correo válida (solo minúsculas, sin acentos ni caracteres especiales).");
|
||||
emailInput.focus();
|
||||
}
|
||||
|
||||
// Validación teléfono
|
||||
const phoneRegex = /^\d{3}\s\d{7}$/;
|
||||
if (!phoneRegex.test(phone)) {
|
||||
alert("El teléfono debe tener el formato 3 dígitos, espacio, 7 dígitos (ej. 123 4567890)");
|
||||
phoneInput.focus();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
// Validación de solo números sin espacios para verificación
|
||||
const digitsOnly = phone.replace(/\s/g, "");
|
||||
if (digitsOnly.length !== 10 || isNaN(digitsOnly)) {
|
||||
alert("El teléfono debe contener exactamente 10 dígitos numéricos.");
|
||||
phoneInput.focus();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user