Ajuste patentes

This commit is contained in:
2025-06-16 16:52:21 -06:00
parent 4365919211
commit f29ac04d50
5 changed files with 238 additions and 271 deletions

View File

@@ -154,17 +154,17 @@
<div class="col-md-1"></div>
<label for="vp_inicio" class="col-md-1 col-form-label">Inicio:</label>
<div class="col-md-1">
<input name="vp_inicio" id="vp_inicio" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vp_inicio" id="vp_inicio" type="text" maxlength="3" class="form-control" value="000">
</div>
<div class="col-md-1"></div>
<label for="vp_final" class="col-md-1 col-form-label">Final:</label>
<div class="col-md-1">
<input name="vp_final" id="vp_final" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vp_final" id="vp_final" type="text" maxlength="3" class="form-control" value="000">
</div>
<div class="col-md-1"></div>
<label for="vp_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
<div class="col-md-1">
<input name="vp_siguiente" id="vp_siguiente" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vp_siguiente" id="vp_siguiente" type="text" maxlength="3" class="form-control" value="000">
</div>
</div><hr>
@@ -174,17 +174,17 @@
<div class="col-md-1"></div>
<label for="vpe_inicio" class="col-md-1 col-form-label">Inicio:</label>
<div class="col-md-1">
<input name="vpe_inicio" id="vpe_inicio" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vpe_inicio" id="vpe_inicio" type="text" maxlength="3" class="form-control" value="000">
</div>
<div class="col-md-1"></div>
<label for="vpe_final" class="col-md-1 col-form-label">Final:</label>
<div class="col-md-1">
<input name="vpe_final" id="vpe_final" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vpe_final" id="vpe_final" type="text" maxlength="3" class="form-control" value="000">
</div>
<div class="col-md-1"></div>
<label for="vpe_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
<div class="col-md-1">
<input name="vpe_siguiente" id="vpe_siguiente" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vpe_siguiente" id="vpe_siguiente" type="text" maxlength="3" class="form-control" value="000">
</div>
</div><hr>
@@ -194,17 +194,17 @@
<div class="col-md-1"></div>
<label for="vat_pb_inicio" class="col-md-1 col-form-label">Inicio:</label>
<div class="col-md-1">
<input name="vat_pb_inicio" id="vat_pb_inicio" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vat_pb_inicio" id="vat_pb_inicio" type="text" maxlength="3" class="form-control" value="000">
</div>
<div class="col-md-1"></div>
<label for="vat_pb_final" class="col-md-1 col-form-label">Final:</label>
<div class="col-md-1">
<input name="vat_pb_final" id="vat_pb_final" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vat_pb_final" id="vat_pb_final" type="text" maxlength="3" class="form-control" value="000">
</div>
<div class="col-md-1"></div>
<label for="vat_pb_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
<div class="col-md-1">
<input name="vat_pb_siguiente" id="vat_pb_siguiente" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vat_pb_siguiente" id="vat_pb_siguiente" type="text" maxlength="3" class="form-control" value="000">
</div>
</div><hr>
@@ -214,17 +214,17 @@
<div class="col-md-1"></div>
<label for="vcc_inicio" class="col-md-1 col-form-label">Inicio:</label>
<div class="col-md-1">
<input name="vcc_inicio" id="vcc_inicio" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vcc_inicio" id="vcc_inicio" type="text" maxlength="3" class="form-control" value="000">
</div>
<div class="col-md-1"></div>
<label for="vcc_final" class="col-md-1 col-form-label">Final:</label>
<div class="col-md-1">
<input name="vcc_final" id="vcc_final" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vcc_final" id="vcc_final" type="text" maxlength="3" class="form-control" value="000">
</div>
<div class="col-md-1"></div>
<label for="vcc_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
<div class="col-md-1">
<input name="vcc_siguiente" id="vcc_siguiente" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vcc_siguiente" id="vcc_siguiente" type="text" maxlength="3" class="form-control" value="000">
</div>
</div><hr>
@@ -234,17 +234,17 @@
<div class="col-md-1"></div>
<label for="vae_inicio" class="col-md-1 col-form-label">Inicio:</label>
<div class="col-md-1">
<input name="vae_inicio" id="vae_inicio" type="text" maxlength="3" class="form-control" placeholder="000" value="000">
<input name="vae_inicio" id="vae_inicio" type="text" maxlength="3" class="form-control" value="000">
</div>
<div class="col-md-1"></div>
<label for="vae_final" class="col-md-1 col-form-label">Final:</label>
<div class="col-md-1">
<input name="vae_final" id="vae_final" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vae_final" id="vae_final" type="text" maxlength="3" class="form-control" value="000">
</div>
<div class="col-md-1"></div>
<label for="vae_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
<div class="col-md-1">
<input name="vae_siguiente" id="vae_siguiente" type="text" maxlength="3" class="form-control" placeholder="000">
<input name="vae_siguiente" id="vae_siguiente" type="text" maxlength="3" class="form-control" value="000">
</div>
</div>
</div>
@@ -327,105 +327,55 @@
return;
}
const vp_inicio = document.getElementById('vp_inicio').value;
const vp_final = document.getElementById('vp_final').value;
const vp_siguiente = document.getElementById('vp_siguiente').value;
const vpe_inicio = document.getElementById('vpe_inicio').value;
const vpe_final = document.getElementById('vpe_final').value;
const vpe_siguiente = document.getElementById('vpe_siguiente').value;
const vat_pb_inicio = document.getElementById('vat_pb_inicio').value;
const vat_pb_final = document.getElementById('vat_pb_final').value;
const vat_pb_siguiente = document.getElementById('vat_pb_siguiente').value;
const vcc_inicio = document.getElementById('vcc_inicio').value;
const vcc_final = document.getElementById('vcc_final').value;
const vcc_siguiente = document.getElementById('vcc_siguiente').value;
const vae_inicio = document.getElementById('vae_inicio').value;
const vae_final = document.getElementById('vae_final').value;
const vae_siguiente = document.getElementById('vae_siguiente').value;
// Obtener campos de folios (ahora VARCHAR)
const folios = [
{ id: 'vp_inicio', nombre: 'VP Inicio' },
{ id: 'vp_final', nombre: 'VP Final' },
{ id: 'vp_siguiente', nombre: 'VP Siguiente' },
{ id: 'vpe_inicio', nombre: 'VPE Inicio' },
{ id: 'vpe_final', nombre: 'VPE Final' },
{ id: 'vpe_siguiente', nombre: 'VPE Siguiente' },
{ id: 'vat_pb_inicio', nombre: 'VAT PB Inicio' },
{ id: 'vat_pb_final', nombre: 'VAT PB Final' },
{ id: 'vat_pb_siguiente', nombre: 'VAT PB Siguiente' },
{ id: 'vcc_inicio', nombre: 'VCC Inicio' },
{ id: 'vcc_final', nombre: 'VCC Final' },
{ id: 'vcc_siguiente', nombre: 'VCC Siguiente' },
{ id: 'vae_inicio', nombre: 'VAE Inicio' },
{ id: 'vae_final', nombre: 'VAE Final' },
{ id: 'vae_siguiente', nombre: 'VAE Siguiente' }
];
// Validaciones Números de Validación y Folios
if (vp_inicio !== '' && !soloNumerosRegex.test(vp_inicio)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vp_inicio').focus();
return;
}
if (vp_final !== '' && !soloNumerosRegex.test(vp_final)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vp_final').focus();
return;
}
if (vp_siguiente !== '' && !soloNumerosRegex.test(vp_siguiente)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vp_siguiente').focus();
return;
}
if (vpe_inicio !== '' && !soloNumerosRegex.test(vpe_inicio)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vpe_inicio').focus();
return;
}
if (vpe_final !== '' && !soloNumerosRegex.test(vpe_final)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vpe_final').focus();
return;
}
if (vpe_siguiente !== '' && !soloNumerosRegex.test(vpe_siguiente)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vpe_siguiente').focus();
return;
}
if (vat_pb_inicio !== '' && !soloNumerosRegex.test(vat_pb_inicio)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vat_pb_inicio').focus();
return;
}
if (vat_pb_final !== '' && !soloNumerosRegex.test(vat_pb_final)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vat_pb_final').focus();
return;
}
if (vat_pb_siguiente !== '' && !soloNumerosRegex.test(vat_pb_siguiente)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vat_pb_siguiente').focus();
return;
}
if (vcc_inicio !== '' && !soloNumerosRegex.test(vcc_inicio)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vcc_inicio').focus();
return;
}
if (vcc_final !== '' && !soloNumerosRegex.test(vcc_final)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vcc_final').focus();
return;
}
if (vcc_siguiente !== '' && !soloNumerosRegex.test(vcc_siguiente)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vcc_siguiente').focus();
return;
}
if (vae_inicio !== '' && !soloNumerosRegex.test(vae_inicio)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vae_inicio').focus();
return;
}
if (vae_final !== '' && !soloNumerosRegex.test(vae_final)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vae_final').focus();
return;
}
if (vae_siguiente !== '' && !soloNumerosRegex.test(vae_siguiente)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vae_siguiente').focus();
return;
// Validar campos de folios
for (let folio of folios) {
const valor = document.getElementById(folio.id).value.trim();
if (valor !== '') {
// Validar longitud máxima
if (valor.length > 10) {
Swal.fire({ icon: 'error', title: 'Campo demasiado largo', text: `${folio.nombre} no puede exceder 10 caracteres.`, confirmButtonColor: '#dc3545' });
document.getElementById(folio.id).focus();
return;
}
// Opcional: Si quieres mantener solo números, descomenta estas líneas
/*
if (!soloNumerosRegex.test(valor)) {
Swal.fire({
icon: 'error',
title: 'Campo inválido',
text: `${folio.nombre} solo puede contener números.`,
confirmButtonColor: '#dc3545'
});
document.getElementById(folio.id).focus();
return;
}
*/
}
}
// ✅ SI TODAS LAS VALIDACIONES PASAN, ENVIAR EL FORMULARIO
// Mostrar indicador de carga
Swal.fire({
title: 'Guardando...', text: 'Por favor espere', allowOutsideClick: false, showConfirmButton: false,
willOpen: () => { Swal.showLoading(); }
});
// Si todas las validaciones pasan, mostrar carga y enviar
Swal.fire({ title: 'Guardando...', text: 'Por favor espere', allowOutsideClick: false, showConfirmButton: false, willOpen: () => { Swal.showLoading(); } });
// SI TODAS LAS VALIDACIONES PASAN, ENVIAR EL FORMULARIO
this.submit();

View File

@@ -163,19 +163,19 @@
<label for="vp_inicio" class="col-md-1 col-form-label">Inicio:</label>
<div class="col-md-1">
<input name="vp_inicio" id="vp_inicio" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vp_inicio'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vp_inicio'] ?? '')) ?>">
</div>
<div class="col-md-1"></div>
<label for="vp_final" class="col-md-1 col-form-label">Final:</label>
<div class="col-md-1">
<input name="vp_final" id="vp_final" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vp_final'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vp_final'] ?? '')) ?>">
</div>
<div class="col-md-1"></div>
<label for="vp_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
<div class="col-md-1">
<input name="vp_siguiente" id="vp_siguiente" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vp_siguiente'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vp_siguiente'] ?? '')) ?>">
</div>
</div><hr>
@@ -186,19 +186,19 @@
<label for="vpe_inicio" class="col-md-1 col-form-label">Inicio:</label>
<div class="col-md-1">
<input name="vpe_inicio" id="vpe_inicio" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vpe_inicio'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vpe_inicio'] ?? '')) ?>">
</div>
<div class="col-md-1"></div>
<label for="vpe_final" class="col-md-1 col-form-label">Final:</label>
<div class="col-md-1">
<input name="vpe_final" id="vpe_final" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vpe_final'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vpe_final'] ?? '')) ?>">
</div>
<div class="col-md-1"></div>
<label for="vpe_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
<div class="col-md-1">
<input name="vpe_siguiente" id="vpe_siguiente" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vpe_siguiente'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vpe_siguiente'] ?? '')) ?>">
</div>
</div><hr>
@@ -209,19 +209,19 @@
<label for="vat_pb_inicio" class="col-md-1 col-form-label">Inicio:</label>
<div class="col-md-1">
<input name="vat_pb_inicio" id="vat_pb_inicio" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vat_pb_inicio'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vat_pb_inicio'] ?? '')) ?>">
</div>
<div class="col-md-1"></div>
<label for="vat_pb_final" class="col-md-1 col-form-label">Final:</label>
<div class="col-md-1">
<input name="vat_pb_final" id="vat_pb_final" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vat_pb_final'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vat_pb_final'] ?? '')) ?>">
</div>
<div class="col-md-1"></div>
<label for="vat_pb_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
<div class="col-md-1">
<input name="vat_pb_siguiente" id="vat_pb_siguiente" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vat_pb_siguiente'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vat_pb_siguiente'] ?? '')) ?>">
</div>
</div><hr>
@@ -232,19 +232,19 @@
<label for="vcc_inicio" class="col-md-1 col-form-label">Inicio:</label>
<div class="col-md-1">
<input name="vcc_inicio" id="vcc_inicio" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vcc_inicio'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vcc_inicio'] ?? '')) ?>">
</div>
<div class="col-md-1"></div>
<label for="vcc_final" class="col-md-1 col-form-label">Final:</label>
<div class="col-md-1">
<input name="vcc_final" id="vcc_final" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vcc_final'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vcc_final'] ?? '')) ?>">
</div>
<div class="col-md-1"></div>
<label for="vcc_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
<div class="col-md-1">
<input name="vcc_siguiente" id="vcc_siguiente" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vcc_siguiente'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vcc_siguiente'] ?? '')) ?>">
</div>
</div><hr>
@@ -255,19 +255,19 @@
<label for="vae_inicio" class="col-md-1 col-form-label">Inicio:</label>
<div class="col-md-1">
<input name="vae_inicio" id="vae_inicio" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vae_inicio'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vae_inicio'] ?? '')) ?>">
</div>
<div class="col-md-1"></div>
<label for="vae_final" class="col-md-1 col-form-label">Final:</label>
<div class="col-md-1">
<input name="vae_final" id="vae_final" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vae_final'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vae_final'] ?? '')) ?>">
</div>
<div class="col-md-1"></div>
<label for="vae_siguiente" class="col-md-1 col-form-label">Siguiente:</label>
<div class="col-md-1">
<input name="vae_siguiente" id="vae_siguiente" type="text" maxlength="3" class="form-control"
value="<?= htmlspecialchars(sprintf('%03d', $agente['vae_siguiente'] ?? '0')) ?>">
value="<?= htmlspecialchars(sprintf('%03d', $agente['vae_siguiente'] ?? '')) ?>">
</div>
</div>
</div>
@@ -350,105 +350,55 @@
return;
}
const vp_inicio = document.getElementById('vp_inicio').value;
const vp_final = document.getElementById('vp_final').value;
const vp_siguiente = document.getElementById('vp_siguiente').value;
const vpe_inicio = document.getElementById('vpe_inicio').value;
const vpe_final = document.getElementById('vpe_final').value;
const vpe_siguiente = document.getElementById('vpe_siguiente').value;
const vat_pb_inicio = document.getElementById('vat_pb_inicio').value;
const vat_pb_final = document.getElementById('vat_pb_final').value;
const vat_pb_siguiente = document.getElementById('vat_pb_siguiente').value;
const vcc_inicio = document.getElementById('vcc_inicio').value;
const vcc_final = document.getElementById('vcc_final').value;
const vcc_siguiente = document.getElementById('vcc_siguiente').value;
const vae_inicio = document.getElementById('vae_inicio').value;
const vae_final = document.getElementById('vae_final').value;
const vae_siguiente = document.getElementById('vae_siguiente').value;
// Obtener campos de folios (ahora VARCHAR)
const folios = [
{ id: 'vp_inicio', nombre: 'VP Inicio' },
{ id: 'vp_final', nombre: 'VP Final' },
{ id: 'vp_siguiente', nombre: 'VP Siguiente' },
{ id: 'vpe_inicio', nombre: 'VPE Inicio' },
{ id: 'vpe_final', nombre: 'VPE Final' },
{ id: 'vpe_siguiente', nombre: 'VPE Siguiente' },
{ id: 'vat_pb_inicio', nombre: 'VAT PB Inicio' },
{ id: 'vat_pb_final', nombre: 'VAT PB Final' },
{ id: 'vat_pb_siguiente', nombre: 'VAT PB Siguiente' },
{ id: 'vcc_inicio', nombre: 'VCC Inicio' },
{ id: 'vcc_final', nombre: 'VCC Final' },
{ id: 'vcc_siguiente', nombre: 'VCC Siguiente' },
{ id: 'vae_inicio', nombre: 'VAE Inicio' },
{ id: 'vae_final', nombre: 'VAE Final' },
{ id: 'vae_siguiente', nombre: 'VAE Siguiente' }
];
// Validaciones Números de Validación y Folios
if (!soloNumerosRegex.test(vp_inicio)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vp_inicio').focus();
return;
}
if (!soloNumerosRegex.test(vp_final)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vp_final').focus();
return;
}
if (!soloNumerosRegex.test(vp_siguiente)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vp_siguiente').focus();
return;
}
if (!soloNumerosRegex.test(vpe_inicio)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vpe_inicio').focus();
return;
}
if (!soloNumerosRegex.test(vpe_final)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vpe_final').focus();
return;
}
if (!soloNumerosRegex.test(vpe_siguiente)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vpe_siguiente').focus();
return;
}
if (!soloNumerosRegex.test(vat_pb_inicio)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vat_pb_inicio').focus();
return;
}
if (!soloNumerosRegex.test(vat_pb_final)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vat_pb_final').focus();
return;
}
if (!soloNumerosRegex.test(vat_pb_siguiente)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vat_pb_siguiente').focus();
return;
}
if (!soloNumerosRegex.test(vcc_inicio)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vcc_inicio').focus();
return;
}
if (!soloNumerosRegex.test(vcc_final)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vcc_final').focus();
return;
}
if (!soloNumerosRegex.test(vcc_siguiente)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vcc_siguiente').focus();
return;
}
if (!soloNumerosRegex.test(vae_inicio)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Inicio solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vae_inicio').focus();
return;
}
if (!soloNumerosRegex.test(vae_final)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Final solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vae_final').focus();
return;
}
if (!soloNumerosRegex.test(vae_siguiente)) {
Swal.fire({ icon: 'error', title: 'Campo inválido', text: 'Siguiente solo puede contener números.', confirmButtonColor: '#dc3545' });
document.getElementById('vae_siguiente').focus();
return;
// Validar campos de folios
for (let folio of folios) {
const valor = document.getElementById(folio.id).value.trim();
if (valor !== '') {
// Validar longitud máxima
if (valor.length > 10) {
Swal.fire({ icon: 'error', title: 'Campo demasiado largo', text: `${folio.nombre} no puede exceder 10 caracteres.`, confirmButtonColor: '#dc3545' });
document.getElementById(folio.id).focus();
return;
}
// Opcional: Si quieres mantener solo números, descomenta estas líneas
/*
if (!soloNumerosRegex.test(valor)) {
Swal.fire({
icon: 'error',
title: 'Campo inválido',
text: `${folio.nombre} solo puede contener números.`,
confirmButtonColor: '#dc3545'
});
document.getElementById(folio.id).focus();
return;
}
*/
}
}
// ✅ SI TODAS LAS VALIDACIONES PASAN, ENVIAR EL FORMULARIO
// Mostrar indicador de carga
Swal.fire({
title: 'Guardando...', text: 'Por favor espere', allowOutsideClick: false, showConfirmButton: false,
willOpen: () => { Swal.showLoading(); }
});
// Si todas las validaciones pasan, mostrar carga y enviar
Swal.fire({ title: 'Guardando...', text: 'Por favor espere', allowOutsideClick: false, showConfirmButton: false, willOpen: () => { Swal.showLoading(); } });
// SI TODAS LAS VALIDACIONES PASAN, ENVIAR EL FORMULARIO
this.submit();