/* FUNCION GENERICA QUE SE USA PARA IMPRIMIR */ function js_Imprimir2(){ var objContenido= document.getElementById("impresion"); var ventana= window.open("_blank","impresion","location=0,menubar=1,resizable=0,status=0,titlebar=0,toolbar=0,top=30,left=30,scrollbars=1,width=799,height=580"); ventana.document.write(encabezadoOK+objContenido.innerHTML+llamaPrint+buttom); ventana.window.location.reload(); } //Selecciona de una forma todos los checkbox segun el nombre especificado function CheckAll(frm, nombre) { var len = frm.elements.length; for (var i = 0; i < len; i++) { var e = frm.elements[i]; if (e.name == nombre) { e.checked = true; } } } //un comentario function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) { d=document; } if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p); } if(!(x=d[n]) && d.all) { x=d.all[n]; } for (i=0; !x && i]/; var mikExp = /[\^\{\}\`\|\<\>]/; var mikExpSinEspacios = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|\<\>\s]/; var val = null; for (i=0; i<(args.length-1); i+=3) { test=args[i+1]; val=MM_findObj(args[i]); if (!error) val2=MM_findObj(args[i]); nm=args[i+2]; //El nombre del CAMPO manda el ALERT if (val) { //nm=val.name; //si es combo if (test.indexOf('is1Combo')!=-1) { if (val.selectedIndex <= 0) { errors+='- \"'+nm+'\" es obligatorio.\n'; error = true; } } if (test.indexOf('is2Combo')!=-1) { if (val.selectedIndex < 0) { errors+='- \"'+nm+'\" es obligatorio.\n'; error = true; } } if (test.indexOf('isCombo')!=-1) { if (val.options[val.selectedIndex].value == 0 ) { if (val.options[val.selectedIndex].value == '00') { }else { errors+='- \"'+nm+'\" es obligatorio.\n'; error = true; } } } else if ((val=val.value)!="") { if (test.indexOf('isTextSinEspacios')!=-1) { if(val.search(mikExpSinEspacios) > -1) { errors+='- \"'+nm+'\" contiene caracteres invalidos (No se admiten espacios): ' + val + '.\n'; error = true; } } else if (test.indexOf('isText')!=-1) { if(val.search(mikExp) > -1) { errors+='- \"'+nm+'\" contiene caracteres invalidos: ' + val + '.\n'; error = true; } } else if (test.indexOf('isURL')!=-1) { if (!(/^(http:\/\/\w+(\.\w+)*\/)?(\w+)?(\/(\w+|\.\.|\.))*(\?\w+=\w+(&\w+=\w+)*)?$/.test(val))) { errors+='- \"'+nm+'\" debe contener un URL valido.\n'; error = true; } } else if (test.indexOf('isPathToFile')!=-1) { //if (!(/^(([A-Za-z0-9_-\(\) ]+|\.\.|\.)\/)*[A-Za-z0-9_-\(\) ]+$/.test(val))) { if (!(/^(([A-Za-z0-9_\(\)]+|\.\.|\.)\/)*[A-Za-z0-9_\(\)]+$/.test(val))) { errors+='- \"'+nm+'\" debe contener una ruta valida a un archivo.\n'; error = true; } } else if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) { errors+='- \"'+nm+'\" debe contener una direccion de correo electronico.\n'; error = true; //} else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(val))) { } else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)+$/.test(val))) { errors+='- \"'+nm+'\" contiene una direccion de correo invalida: ' + val + '.\n'; error = true; } } else if (test.indexOf('isDate')!=-1) { dia = val.substring(0,2); s1 = val.substring(2,3); mes = val.substring(3,5); s2 = val.substring(5,6); ano = val.substring(6,10); if ( (val.length!=10) || // el formato de fecha es de 10 caracteres (isNaN(dia)) || // verificar el dia (isNaN(mes)) || // verificar el mes (isNaN(ano)) || // verificar el anio (s1!="/") || (s2!="/") ) { // verificar los separadores errors+='- \"'+nm+'\" debe contener una fecha (dd/mm/aaaa).\n'; error = true; } else if ((ano < 1900) || (ano > 2079)) { errors+='- \"'+nm+'\" contiene una fecha invalida: ' + val + '.\n'; error = true; } else if (!validaFecha(dia,mes,ano)) { errors+='- \"'+nm+'\" contiene una fecha invalida: ' + val + '.\n'; error = true; } } else if (test.indexOf('isTime')!=-1) { hora = val.substring(0,2); sep = val.substring(2,3); min = val.substring(3,5); if ( (val.length!=5) || // el formato de horario es de 5 caracteres ##:## (isNaN(hora)) || // verificar la hora (isNaN(min)) || // verificar el minuto (sep!=":")) { // verificar el separador errors+='- \"'+nm+'\" debe contener una hora (hh:mm de 00:00 a 23:59).\n'; error = true; } else if ((hora < 0) || (hora > 23) || (min < 0) || (min > 59)) { errors+='- \"'+nm+'\" contiene una hora invalida: ' + val + '.\n'; error = true; } } else if (test.indexOf('isBeneficiario')!=-1) { /////////// var strCadena = val; if (strCadena.length > 0) { for (var nIndex = 0; nIndex < strCadena.length; nIndex++){ var car = strCadena.charAt(nIndex); if ( (!isNumero(car)) && (!isCorrectChar(car)) ){ //alert(car); errors+='- \"'+nm+'\" no es caracter valido : ' + car + '.\n'; error = true; } } } }else if (test.indexOf('isReferenciaUsuario')!=-1) { /////////// var strCadena = val; if (strCadena.length > 0) { for (var nIndex = 0; nIndex < strCadena.length; nIndex++){ var car = strCadena.charAt(nIndex); if ( (!isNumero(car)) && (!isCorrectCharSinEspacios(car)) ){ //alert(car); errors+='- \"'+nm+'\" no es caracter valido : ' + car + '.\n'; error = true; } } } //////////////// } else if (test.indexOf('isRomano')!=-1) { var strCadena = val; if (strCadena.length > 0) { for (var nIndex = 0; nIndex < strCadena.length; nIndex++){ var car = strCadena.charAt(nIndex); if (!isCorrectRoman(car)){ //alert(car); errors+='- \"'+nm+'\" no es numero romano valido (verifique mayusculas): ' + car + '.\n'; error = true; } } } } else if ( test.indexOf('isCuentaBancaria') != -1 ){ if ( ! cuentaBancaria( val) ){ error = true; errors +='- \"'+nm+'\" No es una cuenta bancaria v?lida : ' + val + '\n'; } } else if ( test.indexOf('isClabe') != -1 ){ if ( ! clabeBancaria( val) ){ error = true; errors +='- \"'+nm+'\" No es una clabe bancaria v?lida : ' + val + '\n'; } } else if ( test.indexOf('isCuentaContable') != -1 ){ if ( ! cuentaContable( val) ){ error = true; errors +='- \"'+nm+'\" No es una clabe bancaria v?lida : ' + val + '\n'; } } else if (test!='R') { num = parseFloat(val); if (test.indexOf('isSignedNum') != -1 || test.indexOf('isNum') != -1) { if (!(/^[-+]?\d+$/.test(val))) { errors+='- \"'+nm+'\" debe contener un numero entero.\n'; error = true; break; } } if (test.indexOf('isMiPorcentaje') != -1 ) { if (!(/^[-+]?\d\d$/.test(val))) { errors+='- \"'+nm+'\" debe contener un numero entero de 2 digitos.\n'; error = true; break; } } if (test.indexOf('isUnsignedNum') != -1 || test.indexOf('isInteger') != -1) { if (!(/^\d+$/.test(val))) { errors+='- \"'+nm+'\" debe contener un n?mero entero sin signo.\n'; error = true; break; } } if (test.indexOf('isOnlyNumbers') != -1) { if (!(/^\d+$/.test(val))) { errors+='- \"'+nm+'\" solo acepta n?meros.\n'; error = true; break; } } if (test.indexOf('isCurrency') != -1) { if (!(/^[-+]?\d*\.\d\d$/.test(val))) { errors+='- \"'+nm+'\" debe contener un numero con 2 decimales.\n'; error = true; } } //////////// if (test.indexOf('isMonto') != -1) { var strCadena = val; var punto = strCadena.indexOf('.'); //strCadena.indexOf('.')){ if (punto >= 0){ if (!(/^[-+]?\d*\.\d\d$/.test(val))){ errors+='- \"'+nm+'\" debe contener un numero con 2 decimales o enteros.\n'; errors+='- \"'+nm+'\" Ej. 9999999.99\n'; error = true; } }else{ if (!(/^\d+$/.test(val))){ errors+='- \"'+nm+'\" debe contener unicamente numeros enteros o con dos decimales.\n'; error = true; }else{ if(!(strCadena.length < 10)){ errors+='- \"'+nm+'\" la longitud debe ser menor a 10 numeros cuando no incluye decimales.\n'; error = true; } } } } // (INICIO) MLH **************** if (test.indexOf('isAnio') != -1) { var strCadena = val; if((strCadena.length > 4)){ errors+='- \"'+nm+'\" la longitud debe ser igual a 4 numeros.\n'; error = true; } if (!(/^\d+$/.test(val))) { errors+='- \"'+nm+'\" solo acepta n?meros.\n'; error = true; break; } } if (test.indexOf('isCosto') != -1) { var strCadena = val; var punto = strCadena.indexOf('.'); if (punto >= 0){ if (!(/^[-+]?\d*\.\d*$/.test(val))){ errors+='- \"'+nm+'\" debe contener un numero con 5 decimales.\n'; errors+='- \"'+nm+'\" Ej. 99.12345\n'; error = true; } }else{ if (!(/^\d+$/.test(val))){ errors+='- \"'+nm+'\" debe contener unicamente numeros enteros o con 5 decimales.\n'; error = true; }else{ if(!(strCadena.length <= 11)){ errors+='- \"'+nm+'\" la longitud debe ser menor a 12 numeros cuando no incluye decimales.\n'; error = true; } } } } if (test.indexOf('isLongitudKm') != -1) { var strCadena = val; var punto = strCadena.indexOf('.'); if (punto >= 0){ if (!(/^[-+]?\d*\.\d*$/.test(val))){ errors+='- \"'+nm+'\" debe contener un numero con 5 decimales.\n'; errors+='- \"'+nm+'\" Ej. 99.12345\n'; error = true; } }else{ if (!(/^\d+$/.test(val))){ errors+='- \"'+nm+'\" debe contener unicamente numeros enteros o con 5 decimales.\n'; error = true; }else{ if(!(strCadena.length <= 6)){ errors+='- \"'+nm+'\" la longitud debe ser menor a 6 numeros cuando no incluye decimales.\n'; error = true; } } } } if (test.indexOf('isLongitudViaKm') != -1) { var strCadena = val; var punto = strCadena.indexOf('.'); if (punto >= 0){ if (!(/^[-+]?\d*\.\d*$/.test(val))){ errors+='- \"'+nm+'\" debe contener un numero con 3 decimales.\n'; errors+='- \"'+nm+'\" Ej. 99.123\n'; error = true; } }else{ if (!(/^\d+$/.test(val))){ errors+='- \"'+nm+'\" debe contener unicamente numeros enteros o con 3 decimales.\n'; error = true; }else{ if(!(strCadena.length <= 7)){ errors+='- \"'+nm+'\" la longitud debe ser menor a 7 numeros cuando no incluye decimales.\n'; error = true; } } } } if (test.indexOf('isLongitudTramoKm') != -1) { var strCadena = val; var punto = strCadena.indexOf('.'); if (punto >= 0){ if (!(/^[-+]?\d*\.\d*$/.test(val))){ errors+='- \"'+nm+'\" debe contener un numero con 2 decimales.\n'; errors+='- \"'+nm+'\" Ej. 99.123\n'; error = true; } }else{ if (!(/^\d+$/.test(val))){ errors+='- \"'+nm+'\" debe contener unicamente numeros enteros o con 2 decimales.\n'; error = true; }else{ if(!(strCadena.length <= 8)){ errors+='- \"'+nm+'\" la longitud debe ser menor a 9 numeros cuando no incluye decimales.\n'; error = true; } } } } if (test.indexOf('isMoFondoReserva') != -1) { var strCadena = val; var punto = strCadena.indexOf('.'); if (punto >= 0){ if (!(/^[-+]?\d*\.\d*$/.test(val))){ errors+='- \"'+nm+'\" debe contener un numero con 4 decimales.\n'; errors+='- \"'+nm+'\" Ej. 99.1234\n'; error = true; } }else{ if (!(/^\d+$/.test(val))){ errors+='- \"'+nm+'\" debe contener unicamente numeros enteros o con 4 decimales.\n'; error = true; }else{ if(!(strCadena.length <= 12)){ errors+='- \"'+nm+'\" la longitud debe ser menor a 13 numeros cuando no incluye decimales.\n'; error = true; } } } } if (test.indexOf('isImpReqAportacion') != -1) { var strCadena = val; var punto = strCadena.indexOf('.'); if (punto >= 0){ if (!(/^[-+]?\d*\.\d*$/.test(val))){ errors+='- \"'+nm+'\" debe contener un numero con 8 decimales.\n'; errors+='- \"'+nm+'\" Ej. 99.12345678\n'; error = true; } }else{ if (!(/^\d+$/.test(val))){ errors+='- \"'+nm+'\" debe contener unicamente numeros enteros o con 8 decimales.\n'; error = true; }else{ if(!(strCadena.length <= 12)){ errors+='- \"'+nm+'\" la longitud debe ser menor a 13 numeros cuando no incluye decimales.\n'; error = true; } } } } if (test.indexOf('isIvaZona') != -1) { var strCadena = val; var punto = strCadena.indexOf('.'); if (punto >= 0){ if (!(/^[-+]?\d*\.\d*$/.test(val))){ errors+='- \"'+nm+'\" debe contener un numero con 7 decimales.\n'; errors+='- \"'+nm+'\" Ej. 999.1234567\n'; error = true; } }else{ if (!(/^\d+$/.test(val))){ errors+='- \"'+nm+'\" debe contener unicamente numeros enteros o con 7 decimales.\n'; error = true; }else{ if(!(strCadena.length <= 3)){ errors+='- \"'+nm+'\" la longitud debe ser menor a 4 numeros cuando no incluye decimales.\n'; error = true; } } } } if (test.indexOf('isCompVehTipo') != -1) { var strCadena = val; var punto = strCadena.indexOf('.'); if (punto >= 0){ if (!(/^[-+]?\d*\.\d*$/.test(val))){ errors+='- \"'+nm+'\" debe contener un numero con 2 decimales.\n'; errors+='- \"'+nm+'\" Ej. 999.12\n'; error = true; } }else{ if (!(/^\d+$/.test(val))){ errors+='- \"'+nm+'\" debe contener unicamente numeros enteros o con 2 decimales.\n'; error = true; }else{ if(!(strCadena.length <= 3)){ errors+='- \"'+nm+'\" la longitud debe ser menor a 4 numeros cuando no incluye decimales.\n'; error = true; } } } } if (test.indexOf('isCoutaVehTipo') != -1) { var strCadena = val; var punto = strCadena.indexOf('.'); if (punto >= 0){ if (!(/^[-+]?\d*\.\d*$/.test(val))){ errors+='- \"'+nm+'\" debe contener un numero con 2 decimales.\n'; errors+='- \"'+nm+'\" Ej. 999.12\n'; error = true; } }else{ if (!(/^\d+$/.test(val))){ errors+='- \"'+nm+'\" debe contener unicamente numeros enteros o con 2 decimales.\n'; error = true; }else{ if(!(strCadena.length <= 3)){ errors+='- \"'+nm+'\" la longitud debe ser menor a 4 numeros cuando no incluye decimales.\n'; error = true; } } } } // (FIN) MLH **************** if (test.indexOf('isPorcentaje') != -1) { var strCadena = val; var punto = strCadena.indexOf('.'); //strCadena.indexOf('.')){ if (punto >= 0){ if (!(/^[-+]?\d*\.\d\d$/.test(val))){ errors+='- \"'+nm+'\" debe contener un numero con 6 decimales.\n'; errors+='- \"'+nm+'\" Ej. 99.123456\n'; error = true; } }else{ if (!(/^\d+$/.test(val))){ errors+='- \"'+nm+'\" debe contener unicamente numeros enteros o con 6 decimales.\n'; error = true; }else{ if(!(strCadena.length <= 3)){ errors+='- \"'+nm+'\" la longitud debe ser menor a 3 numeros cuando no incluye decimales.\n'; error = true; } } } } ////////// if (test.indexOf('isFloat') != -1) { if (!(/^[-+]?\d*\.?\d+$/.test(val))) { errors+='- \"'+nm+'\" debe contener un numero.\n'; error = true; } } if (test.indexOf('isPorcent4_4') != -1) { if (!(/^[-+]?\d\d\d\d\.\d\d\d\d$/.test(val))) { errors+='- \"'+nm+'\" debe contener un numero con 4 enteros 4 decimales.\n'; error = true; } } if (test.indexOf('isPorcent2_5') != -1) { if (!(/^[-+]?\d\d\.\d\d\d\d\d$/.test(val))) { errors+='- \"'+nm+'\" debe contener un numero con 2 enteros y 5 decimales.\n'; error = true; } } if (test.indexOf('isPorcent1_1') != -1) { if (!(/^[-+]?\d\.\d$/.test(val))) { errors+='- \"'+nm+'\" debe contener un numero con 1 entero 1 decimal.\n'; error = true; } } if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num 31) || (myMonthStr > 12)) { return false; } var myDate = new Date(myYearStr, myMonthStr-1, myDayStr); /* Cuando una fecha es invalida, al convertirla a Date() el mes (getMonth()) se recorre automaticamente, resultando diferente de myMonthStr-1 */ return (parseInt(myDate.getMonth())) == parseInt(myMonthStr-1); } function TextoCorrecto(strCadena) { var nIndex = 0; if (strCadena.length > 0) { for (nIndex ; nIndex < strCadena.length; nIndex++) { if ((strCadena.charAt(nIndex) == "<") || (strCadena.charAt(nIndex) == ">") || (strCadena.charAt(nIndex) == "&")) return false; } } return true; } function formatCurrency( num ) { var isNegative = false; num = num.toString().replace(/\\$|\\,/g,''); if( isNaN( num ) ) { num = "0"; } if ( num < 0 ) { num = Math.abs( num ); isNegative = true; } cents = Math.floor( ( num * 100 + 0.5 ) % 100 ); num = Math.floor( ( num * 100 + 0.5 ) / 100 ).toString(); if ( cents < 10 ) { cents = "0" + cents; } for ( i = 0; i < Math.floor( ( num.length - ( 1 + i ) ) / 3 ); i++) { num = num.substring( 0 ,num.length - ( 4 * i + 3 ) ) + ',' + num.substring( num.length - ( 4 * i + 3 ) ); } var result = num + '.' + cents; if ( isNegative ) { result = "-" + result; } return result; } // FUNCIONES GENERALES DE JAVA // Este archivo se debe encontrar en la carpeta _private // Trim.- Elimina los espacios de la derecha y de la izquierda de una "Cadena" function Trim(strCadena) // Debe ir en un archivo de Funciones { var strCadenaTmp; var nIndex, nIndex2; for (nIndex=0; nIndex < strCadena.length; nIndex++) { if (strCadena.charAt(nIndex) != " ") { break; } /*else if (strVar.charAt(nIndex) != " ") CadenaTmp=Concatenar(CadenaTmp, strVar.charAt(nIndex));*/ } for (nIndex2 = strCadena.length-1; nIndex2 >= 0 && nIndex < strCadena.length; nIndex2--) { if (strCadena.charAt(nIndex2) != " ") { break; } } //Se concatenan CadenaTmp desde nIndex hasta nIndex2 strCadenaTmp = "" if (nIndex <= nIndex2) strCadenaTmp = strCadena.substring(nIndex, nIndex2 + 1); return strCadenaTmp; } function NumCorrectoLongitudExacta( strNumero, longitud){ if ( NumeroCorrecto( strNumero ) ){ if ( strNumero.length != longitud ) return false; return true; } else return false; } function cuentaBancaria( strNumero ){ if ( NumCorrectoLongitudExacta( strNumero, 11) ) return true; return false; } function clabeBancaria( strNumero ){ if ( NumCorrectoLongitudExacta( strNumero, 18) ) return true; return false; } function cuentaContable( strNumero ){ if ( NumCorrectoLongitudExacta( strNumero, 12) ) return true; return false; } // NumeroCorrecto.- Valida que una Cadena sea un 'n?mero entero' v?lido function NumeroCorrecto(strCadena) { var nIndex = 0; if (strCadena.length > 0) { for (nIndex ; nIndex < strCadena.length; nIndex++) { if ((strCadena.charAt(nIndex) < "0") || (strCadena.charAt(nIndex) > "9")) return false; } } return true; } // DecimalCorrecto.- Valida que una Cadena sea un 'n?mero double' v?lido function DecimalCorrecto(strCadena) { var nIndex = 0; var numPuntos = 0; if (strCadena.length > 0) { for (nIndex ; nIndex < strCadena.length; nIndex++) { if ((strCadena.charAt(nIndex) < "0") || (strCadena.charAt(nIndex) > "9")){ if(!(strCadena.charAt(nIndex) == '.' && ++numPuntos <= 1)){ return false; } } } } return true; } // TextoCorrecto.- Valida que una Cadena no contenga los simbolos < , > y & function TextoCorrecto(strCadena) { var nIndex = 0; if (strCadena.length > 0) { for (nIndex ; nIndex < strCadena.length; nIndex++) { if ((strCadena.charAt(nIndex) == "<") || (strCadena.charAt(nIndex) == ">") || (strCadena.charAt(nIndex) == "&")) return false; } } return true; } //////////////////////////////////////// function isNumero(car){ if (car < "0" || car > "9"){ return false; } return true; } function isCorrectChar(car){ if( (car!=' ') && (car < "A" || car > "Z") && (car < "a" || car > "z") ){ return false; } return true; } function isCorrectCharSinEspacios(car){ if( (car < "A" || car > "Z") && (car < "a" || car > "z") ){ return false; } return true; } function isCorrectRoman(car){ if(car != "X" || car != "I" || car != "L" || car != "C" || car != "V" || car != "D" || car != "M"){ return false; } return true; } //////////////////////////////////// //getParameter.- Regresa un parametro de una liga url function getParameter(liga,parametro){ var posLiga, posParam = -1; var enCharEspecial = false; var enValor = false; var valor = ""; parametro += "="; for (posLiga = 0 ;posLiga < liga.length; posLiga++){ if(liga.charAt(posLiga) == "?" || liga.charAt(posLiga) == "&"){ if(enValor){ return valor; }else{ enCharEspecial = true; } }else{ if(enValor){ valor += liga.charAt(posLiga); }else{ if(enCharEspecial){ if(liga.charAt(posLiga) == parametro.charAt(++posParam)){ if(posParam == parametro.length-1){ enValor = true } }else{ enCharEspecial = false; posParam = -1; } } } } } return valor; } //validaFrames.- Si la pagina no esta dentro de frames manda a pagina de error function validaFrames(){ var ns = navigator.appName == "Netscape"; if(!ns){ if(window.parent.document.all["body"]){ document.location.href = "Error.jsp?" + "funcion=No definido" + "&error=" + "La p?gina solicitada es inv?lida"; } } } //comboValue.- Regresa el valor del objeto seleccionado function comboValue(combo){ return combo.options[combo.selectedIndex].value; } //comboTexto.- Regresa el texto del objeto seleccionado function comboTexto(combo){ return combo.options[combo.selectedIndex].text; } //radioValue.- Regresa el valor del radio boton se?alado o cadena vacia si //ninguno esta se?alado function radioValue(radio){ for(i=0; i