1// Validar cif 2function checkCIF(value){ 3 4 var num = [], 5 controlDigit, sum, i, count, tmp, secondDigit; 6 7 value = value.toUpperCase(); 8 9 // Quick format test 10 if ( !value.match( "((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)" ) ) { 11 return false; 12 } 13 14 for ( i = 0; i < 8; i++ ) { 15 num[ i ] = parseInt(value.charAt( i ), 10); 16 } 17 num[ 8 ] = value.charAt( 8 ); 18 19 // Algorithm for checking CIF codes 20 sum = num[ 2 ] + num[ 4 ] + num[ 6 ]; 21 for ( count = 1; count < 8; count += 2 ) { 22 tmp = ( 2 * num[ count ] ).toString(); 23 secondDigit = tmp.charAt( 1 ); 24 25 sum += parseInt( tmp.charAt( 0 ), 10 ) + ( secondDigit === "" ? 0 : parseInt( secondDigit, 10 ) ); 26 } 27 28 /* The first (position 1) is a letter following the following criteria: 29 * A. Corporations 30 * B. LLCs 31 * C. General partnerships 32 * D. Companies limited partnerships 33 * E. Communities of goods 34 * F. Cooperative Societies 35 * G. Associations 36 * H. Communities of homeowners in horizontal property regime 37 * J. Civil Societies 38 * K. Old format 39 * L. Old format 40 * M. Old format 41 * N. Nonresident entities 42 * P. Local authorities 43 * Q. Autonomous bodies, state or not, and the like, and congregations and religious institutions 44 * R. Congregations and religious institutions (since 2008 ORDER EHA/451/2008) 45 * S. Organs of State Administration and regions 46 * V. Agrarian Transformation 47 * W. Permanent establishments of non-resident in Spain 48 */ 49 if ( /^[ABCDEFGHJNPQRSUVW]{1}/.test( value ) ) { 50 sum += ""; 51 controlDigit = 10 - parseInt( sum.charAt( sum.length - 1 ), 10 ); 52 value += controlDigit; 53 return ( num[ 8 ].toString() === String.fromCharCode( 64 + controlDigit ) || num[ 8 ].toString() === value.charAt( value.length - 1 ) ); 54 } 55 56 return false; 57} 58 59// Valida nif 60function checkNIF(nif) 61{ 62 if (!nif) return false; 63 var letras = 'TRWAGMYFPDXBNJZSQVHLCKE'; 64 var cleanNif = nif.toString().trim().toUpperCase().replace(/[\s\-\.\,]/g, ''); 65 if (cleanNif.length < 9) return false; 66 var letra = cleanNif.substr(cleanNif.length - 1, 1); 67 var dni = cleanNif.substr(0, cleanNif.length - 1); 68 dni = dni.replace('X', '0').replace('Y', '1').replace('Z', '2'); 69 if (!/^[0-9]+$/.test(dni)) return false; 70 var index = parseInt(dni, 10) % 23; 71 return letras.charAt(index) === letra; 72} 73 74function letraDni(dni) { 75 dni = dni.toUpperCase(); 76 //Para NIEs 77 if (dni[0] == "X") dni = "0" + dni.substr(1); 78 if (dni[0] == "Y") dni = "1" + dni.substr(1); 79 if (dni[0] == "Z") dni = "2" + dni.substr(1); 80 var lockup = 'TRWAGMYFPDXBNJZSQVHLCKE'; 81 return lockup.charAt(dni % 23); 82 } 83 84function isNIF(field, rules, i, options) { 85 if (!checkNIF(field.val())) { 86 return options.allrules.validate2fields.alertText; 87 } 88} 89 90function isCIF(field, rules, i, options) { 91 if (!checkCIF(field.val())) { 92 return options.allrules.validate3fields.alertText; 93 } 94} 95 96function isCIForNIF(field, rules, i, options) { 97 if (!checkCIF(field.val()) && !checkNIF(field.val())) { 98 return options.allrules.validate3fields.alertText; 99 } 100} 101 102function isUser(field, rules, i, options) { 103 if (!checkMobile(field.val()) && !email_validation(field.val())) { 104 return options.allrules.validate2fields.alertText; 105 } 106} 107 108function isMobile(field, rules, i, options) { 109 if (!checkMobile(field.val())) { 110 return options.allrules.phone.alertText; 111 } 112} 113 114function isPhone(field, rules, i, options) { 115 if (!checkPhone(field.val())) { 116 return options.allrules.phone.alertText; 117 } 118} 119 120// Valida numero seguridad social 121function checkNSS(nss) 122{ 123 if (!nss) return false; 124 if (nss.length != 11 && nss.length != 12) return false; 125 if (nss.substr(2, 1) == 0) nss = "" + nss.substr(0, 2) + nss.substr(3, nss.length-1); 126 if (mod(nss.substr(0, nss.length-2), 97) == nss.substr(nss.length-2, 2)) return true; 127 else return false; 128} 129 130// COMPROBAR URL 131function ValidaURL(url) { var regex=/^(ht|f)tps?:\/\/\w+([\.\-\w]+)?\.([a-z]{2,4}|travel)(:\d{2,5})?(\/.*)?$/i; return regex.test(url); } 132 133// COMROBAR IMAGEN 134function validarImagen(iarray) 135{ 136 ok=true; 137 if(iarray!=""){ 138 var cadena1 = iarray; //tomo el valor del primer input 139 var s = cadena1.lastIndexOf("."); //obtengo la posision del ultimo punto en la cadena(el que precede a la extencion) 140 var miarr = new Array("jpeg","jpg","png"); //Declaro un array con las extensiones permitidas 141 for (i = 0; i < miarr.length; i++) //bucle en el que compruebo las extensiones permitidas 142 { 143 var charfind = cadena1.substr(s+1,4); //extraigo las ultimas 4 letras despues del punto (posision 's+1') 144 charfind = charfind.toLowerCase(); //convierto la extraccion a minisculas para evitar comprobaciones erroneas
145 if(charfind == miarr[i]) //compruebo la extencion obtenida con las permitidas 146 { 147 //alert("Archivo "+(m+1)+" validado"); //si es correcta aviso que esta validado 148 149 break; //termino blucle 150 //ok= true 151 } 152 if(i == miarr.length - 1 && cadena1!="") //si se ha llegado a la ultima pasada en el bucle aviso que se ha introducido una extension erronea 153 { 154 155 //return false; 156 ok=false; 157 } 158 } 159 } 160 161 return ok; 162} 163// COMPROBAR EMAIL 164function email_validation(texto){ 165 166 var s = texto; 167 var filter = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/; 168 169 if (s.length == 0 ) return false; 170 if (filter.test(s)) 171 return true; 172 else 173 return false; 174} 175 176// check a phone field 177function checkPhone( val ){ 178 var regexp = /^([6|7|9])+[0-9]{8}/; 179 return ((val!='') && (val.match(regexp))); 180} 181 182function checkMobile( val ){ 183 var regexp = /^([6|7])+[0-9]{8}/; 184 return ((val!='') && (val.match(regexp))); 185} 186 187// check skype user name 188function checkSkype( field, rules, i, opts ){ 189 190 if( field.attr('id') == '_skype' ){ 191 var skype = $('#_skype').val(); 192 }else{ 193 var skype = $('#_skype').val(); 194 } 195 regexp = /^[A-Za-z]{1}([A-Za-z0-9]|[-_.,]){5,31}$/; 196 197 if( !skype.match(regexp) && skype != '' ){ 198 199 return _funciones_skype_user_err; 200 } 201 202} 203 204function scrollto (obj, tiempo) { 205 if (typeof $(obj).offset() != "undefined") { 206 if (typeof tiempo == "undefined") 207 tiempo = 1000; 208 209 $('html, body').animate({ 210 scrollTop: $(obj).offset().top - 110 211 }, tiempo); 212 } 213} 214 215 216var normalize = (function() { 217 var from = "ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃãà áäâèéëêìÃïîòóöôùúüûÃñÃç", 218 to = "AAAAAEEEEIIIIOOOOUUUUaaaaaeeeeiiiioooouuuunncc", 219 mapping = {}; 220 221 for(var i = 0, j = from.length; i < j; i++ ) 222 mapping[ from.charAt( i ) ] = to.charAt( i ); 223 224 return function( str, comodin ) { 225 var ret = []; 226 if (comodin === undefined) 227 comodin = '-'; 228 for( var i = 0, j = str.length; i < j; i++ ) { 229 var c = str.charAt( i ); 230 if( mapping.hasOwnProperty( str.charAt( i ) ) ) 231 ret.push( mapping[ c ] ); 232 else 233 ret.push( c ); 234 } 235 return ret.join( '' ).replace( /[^-A-Za-z0-9]+/g, comodin ).toLowerCase();; 236 } 237 238})(); 239 240if(typeof String.prototype.trim !== 'function') { 241 String.prototype.trim = function() { 242 return this.replace(/^\s+|\s+$/g, ''); 243 } 244} 245if(typeof String.prototype.replaceAll !== 'function') { 246 String.prototype.replaceAll = function(search, replacement) { 247 var target = this; 248 return target.replace(new RegExp(search, 'g'), replacement); 249 }; 250} 251 252function oculta_email(email) { 253 var arr_aux = email.split("@"); 254 var result = arr_aux[0][0] + "?".padStart(arr_aux[0].length-1, "?") + "@" + arr_aux[1]; 255 return result; 256} 257 258function muestra_aviso_info (txt) { 259 swal({ 260 title: '<?php echo ___ERROR/*¡Error!*/;?>', 261 text: txt, 262 type: 'info', 263 allowOutsideClick: true, 264 allowEscapeKey: true, 265 showCloseButton: true,
266 showCancelButton: false, 267 showConfirmButton: true, 268 confirmButtonText: 'Ok' 269 }); 270} 271 272 273function check_type(e) { 274 tecla = (document.all) ? e.keyCode : e.which; 275 276 //Tecla de retroceso para borrar, siempre la permite 277 if (tecla == 8) { 278 return true; 279 } 280 281 // Patron de entrada, en este caso solo acepta numeros y letras 282 patron = /[A-Za-z0-9]/; 283 tecla_final = String.fromCharCode(tecla).toUpperCase(); 284 return patron.test(tecla_final); 285} 286 287function check_type_tildes(e, elemento, mayusculas) { 288 tecla=(document.all) ? e.keyCode : e.which; 289 var val_inicio = elemento.value; 290 var val_cambio; 291 if (mayusculas) 292 val_cambio = elemento.value.toUpperCase(); 293 val_cambio = normalize(elemento.value, ''); 294 if (val_cambio != val_inicio) 295 elemento.value = val_cambio; 296} 297 298 299function aMays(e, elemento) { 300 tecla=(document.all) ? e.keyCode : e.which; 301 if (tecla == 192 || tecla == 222) { 302 e.preventDefault(); 303 e.stopPropagation(); 304 } else 305 elemento.value = elemento.value.toUpperCase(); 306}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.