function esdv2(rut,dv){ indice=2; total=0; validar = rut; if(dv=="k") dv="K"; if(validar.length<7){ return 0; } for(i=validar.length-1;i>=0;i--) { if(validar.charCodeAt(i)>=48&&validar.charCodeAt(i)<=57) { if(indice<=7) { total=total+parseInt(validar.charAt(i))*indice; indice++; } else { indice=2; total=total+parseInt(validar.charAt(i))*indice; indice++; } } } total=11-(total-(Math.floor(total/11)*11)); if(total==11) total="0"; if(total==10) total="K"; //alert(dv); //alert(total); if(dv!=total){ return 0; } return 1; } function Trim( str ) { var resultStr = ""; resultStr = TrimLeft(str); resultStr = TrimRight(resultStr); return resultStr; } function TrimLeft( str ) { var resultStr = ""; var i = len = 0; // Return immediately if an invalid value was passed in if (str+"" == "undefined" || str == null) return null; // Make sure the argument is a string str += ""; if (str.length == 0) resultStr = ""; else { // Loop through string starting at the beginning as long as there // are spaces. // len = str.length - 1; len = str.length; while ((i <= len) && (str.charAt(i) == " ")) i++; // When the loop is done, we're sitting at the first non-space char, // so return that char plus the remaining chars of the string. resultStr = str.substring(i, len); } return resultStr; } function TrimRight( str ) { var resultStr = ""; var i = 0; // Return immediately if an invalid value was passed in if (str+"" == "undefined" || str == null) return null; // Make sure the argument is a string str += ""; if (str.length == 0) resultStr = ""; else { // Loop through string starting at the end as long as there // are spaces. i = str.length - 1; while ((i >= 0) && (str.charAt(i) == " ")) i--; // When the loop is done, we're sitting at the last non-space char, // so return that char plus all previous chars of the string. resultStr = str.substring(0, i + 1); } return resultStr; } //Valida EMAIL function isMail(_email) { var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i return emailReg.test(_email); } function esNumero(){ if((event.keyCode < 48)||(event.keyCode > 57)){ alert("Ingrese sólo números."); event.keyCode = 0; } } function esRut(validar){ indice=2; total=0; dv=0; if(validar.length<7){ alert('Rut Inválido: Menos de Siete digitos.'); window.document.form.f_user.select(); window.document.form.f_user.focus(); return false; } for(i=validar.length-1;i>=0;i--) { if(validar.charCodeAt(i)>=48&&validar.charCodeAt(i)<=57) { if(indice<=7) { total=total+parseInt(validar.charAt(i))*indice; indice++; } else { indice=2; total=total+parseInt(validar.charAt(i))*indice; indice++; } } } total=11-(total-(Math.floor(total/11)*11)); if(total==11) dv="0"; if(total==10) dv="K"; if(total<10) dv= total ; esRut= dv return esRut; } function doPrint() { tblbotones.style.display="none" //document.all.item("printtitle").style.display="" // -- advanced features // factory.printing.SetMarginMeasure(2); // measure margins in inches // factory.printing.printer = "HP DeskJet 870C"; // factory.printing.paperSize = "A4"; // factory.printing.paperSource = "Manual feed"; // factory.printing.collate = true; // factory.printing.copies = 2; // factory.printing.SetPageRange(false, 1, 3); // need pages from 1 to 3 // -- basic features factory.printing.header = ""; factory.printing.footer = ""; factory.printing.portrait = false; // factory.printing.leftMargin = 1.0; // factory.printing.topMargin = 1.0; // factory.printing.rightMargin = 1.0; // factory.printing.bottomMargin = 1.0; factory.printing.Print(false) document.all.item("noprint").style.display="" document.all.item("printtitle").style.display="none" } function esNumero2(){ if(((event.keyCode < 48)||(event.keyCode > 57)) && (event.keyCode != 13)){ alert("Ingrese sólo números."); event.keyCode = 0; } }