function validarRegistro() { $("#errorDoc").hide(); $("#errorPais").hide(); $("#errorMail").hide(); $("#errorPasswords").hide(); if($("#tipoDocumento").val() == '1') { if(!validarCedula($("#documento").val())) { $("#errorDoc").show(); $("#infoError").hide(); return false; } } else { if($("#paisPasaporte").val() == 'null') { $("#errorPais").show(); $("#infoError").hide(); return false; } } if(!validarEmail($("#email").val())) { $("#errorMail").show(); $("#infoError").hide(); return false; } if(!validarPasswords($("#pwd").val().trim(), $("#pwd2").val().trim())) { $("#errorPasswords").show(); $("#infoError").hide(); return false; } //if(validarCaptcha()) return true; } function validarModificar() { $("#errorDoc").hide(); $("#errorPais").hide(); $("#errorMail").hide(); if($("#tipoDocumento").val() == '1') { if(!validarCedula($("#documento").val())) { $("#errorDoc").show(); $("#infoError").hide(); return false; } } else { if($("#paisPasaporte").val() == 'null') { $("#errorPais").show(); $("#infoError").hide(); return false; } } if(!validarEmail($("#email").val())) { $("#errorMail").show(); $("#infoError").hide(); return false; } return true; } function validarResetPassword() { if(!validarPasswords($("#pwd").val().trim(), $("#pwd2").val().trim())) { $("#errorPasswords").show(); return false; } //if(validarCaptcha()) return true; } function validarEmail(email) { var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; return emailPattern.test(email); } function validarPasswords(pwd1, pwd2) { if(pwd1 == "" || pwd2 == "") return false; if(pwd1 != pwd2) return false; return true; } function validarCaptcha() { if(grecaptcha.getResponse().length == 0) { mostrarMsj('Es necesario validar captcha'); return false; } return true; } function validarArchivo() { if($("#archivo").val().trim()=="") { mostrarMsj('Seleccione archivo'); return false; } //$("#button").attr("disabled","disabled"); setTimeout(function() { grisarBoton($("#button")); }, 1); return true; } function validoActualizar() { setTimeout(function() { grisarBoton($("#buttonAct"));}, 1); return true; } function grisarBoton(boton) { boton.attr("disabled","disabled"); return true; } /*** CEDULA ***/ function validarCedula(ci) { ci = limpiarCedula(ci); var dig = ci[ci.length - 1]; ci = ci.replace(/[0-9]$/, ''); return (dig == digitoVerificador(ci)); } function limpiarCedula(ci){ return ci.replace(/\D/g, ''); } function digitoVerificador(ci) { var a = 0; var i = 0; if(ci.length <= 6) { for(i = ci.length; i < 7; i++) { ci = '0' + ci; } } for(i = 0; i < 7; i++) { a += (parseInt("2987634"[i]) * parseInt(ci[i])) % 10; } if(a % 10 === 0) { return 0; } else { return 10 - a % 10; } } function ciSoloNumero(evt) { if($("#tipoDocumento").val() == '1') { var charCode = (evt.which) ? evt.which : evt.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; } return true; } function changeTipoDocumento() { if($("#tipoDocumento").val() == '2' || $("#tipoDocumento").val() == '3') { //El tipo "Otro" pasó a tener país $("#paisPasaporteDiv").show(); } else { $("#paisPasaporteDiv").hide(); } }