
function isValidCif(abc){
	
	par = 0;
	
	non = 0;
	
	letras = "ABCDEFGHKLMNPQS";
	
	let = abc.charAt(0);
	
	
	if (abc.length!=9) {
		
		//alert('El Cif debe tener 9 dÃ­gitos');
		
		return false;
		
	}
	

	
	if (letras.indexOf(let.toUpperCase())==-1) {
		
		//alert("El comienzo del Cif no es vÃ¡lido");
		
		return false;
		
	}
	

	
	for (zz=2;zz<8;zz+=2) {
		
		par = par+parseInt(abc.charAt(zz));
		
	}
	

	
	for (zz=1;zz<9;zz+=2) {
		
		nn = 2*parseInt(abc.charAt(zz));
		
		if (nn > 9) nn = 1+(nn-10);
		
		non = non+nn;
		
	}
	

	
	parcial = par + non;
	
	control = (10 - ( parcial % 10));
	
	if (control==10) control=0;
	

	
	if (control!=abc.charAt(8)) {
		
		//alert("El Cif no es vÃ¡lido");
		
		return false;
		
	}
	
	//alert("El Cif es vÃ¡lido");
	
	return true;
	
}





function isValidNif(abc){
	
	dni=abc.substring(0,abc.length-1);
	
	let=abc.charAt(abc.length-1);
	
	if (!isNaN(let)) {
		
		alert('Falta la letra del NIF');
		
		return false;
		
	}else{
		
		cadena = "TRWAGMYFPDXBNJZSQVHLCKET";
		
		posicion = dni % 23;
		
		letra = cadena.substring(posicion,posicion+1);
		
		if (letra!=let.toUpperCase()){
			
			alert("Nif no vÃ¡lido, por favor, verifÃ­quelo.");
			
			return false;
			
		}
		
	}
	
	//alert("Nif vÃ¡lido")
	
	return true;
	
}







function isValidEmail(str){
	
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	
	return (filter.test(str));
	
}



function isValidTelef(num){
	
	if(num.length < 9){
		
		return false;
		
	}else if(isNaN( num )){
		
		return false;
		
	}else{
		
		return true;
		
	}
	
}



function isValidDateFormat(str){
	
	var filter=/^(\d{1,2}\/\d{1,2}\/\d{4})$/i;
	
	return (filter.test(str));
	
}


function isValidDC(numcuenta)
{
	var numero, total,total1,total2,subtotal,subtotal2;
	var digitos;
	numero = 0;
	total = 0;
	subtotal = 0;
	
	c1 = numcuenta.substr(0,4);
	c2 = numcuenta.substr(4,4);
	c3 = numcuenta.substr(8,2);
	c4 = numcuenta.substr(10,10);
	numero = c1 + c2;
	total = parseInt(total + (numero%10)*6);
	numero = parseInt(numero/10);
	total = parseInt(total + (numero%10)*3);
	numero = parseInt(numero/10);
	total = parseInt(total + (numero%10)*7);
	numero = parseInt(numero/10);
	total = parseInt(total + (numero%10)*9);
	numero = parseInt(numero/10);
	total = parseInt(total + (numero%10)*10);
	numero = parseInt(numero/10);
	total = parseInt(total + (numero%10)*5);
	numero = parseInt(numero/10);
	total = parseInt(total + (numero%10)*8);
	numero = parseInt(numero/10);
	total = parseInt(total + (numero%10)*4);
	numero = parseInt(numero/10);
	total = total%11;
	subtotal = 11-(total%11)
	if(subtotal==11) {
	 subtotal=0;
	 }
	 else if(subtotal==10){ 
	  subtotal=1;
	}  
	total1 = 0;
	total2=0;
	total = c4;
	total1 = total.charAt(9);
	total2 = total1*6;
	total1 = 0
	total1= total.charAt(8);
	total2= total2 + (total1*3);
	total1=0;
	total1= total.charAt(7);
	total2= total2 + (total1*7);
	total1=0
	total1= total.charAt(6);
	total2= total2 + (total1*9);
	total1=0
	total1= total.charAt(5);
	total2= total2 + (total1*10);
	total1=0
	total1= total.charAt(4);
	total2= total2 + (total1*5);
	total1=0
	total1= total.charAt(3);
	total2= total2 + (total1*8);
	total1=0
	total1= total.charAt(2);
	total2= total2 + (total1*4);
	total1=0
	total1= total.charAt(1);
	total2= total2 + (total1*2);
	total1=0
	total1= total.charAt(0);
	total2= total2 + (total1*1);
	total = total2;
	total = total %11;
	subtotal2 = 11 - (total%11);
	if (subtotal2 == 11) {
	 subtotal2=0;
	}
	else if (subtotal2==10) {
	 subtotal2=1;
	}
	return ((subtotal+""+subtotal2) == c3);
}


function blockLetters(e) {
    key = (document.all) ? e.keyCode : e.which;
    //alert(key);
    if (key==8) return true; //Tecla de retroceso (para poder borrar)
    if (key==9) return true; //Tecla TAB
    if (key==17) return true; //Tecla TAB
    if (key >= 95 && key <= 105) return true; // teclado numérico
    patron = /\d/; // Solo acepta números
    te = String.fromCharCode(key);
    //if (!te.length) return true;
    return patron.test(te); 
} 

