// JavaScript Document

/*	FUNCIÓN PARA CONTROLAR QUE SEA UN Nº LO QUE INTRODUCEN*/
function LP_data(){ 
  var key=window.event.keyCode;//codigo de tecla. 
  if (key < 48 || key > 57){//si no es numero  
    window.event.keyCode=0;//anula la entrada de texto. 
  }
} 

/*	FUNCIÓN PARA COMPROBAR QUE EL E-MAIL ES CORRECTO	*/
function isEmailAddress(theElement, nombre_del_elemento ){
	var s = theElement.value;
	var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (s.length == 0 ) return true;
	if (filter.test(s)){
		return true;
	}else{
		alert("Ingrese una dirección de correo válida");
		theElement.focus();
		return false;
	}
}
/*	FUNCIÓN PARA VALIDAR EL DNI	*/
function CompruebaDNI(theElement, nombre_del_elemento) {
  dni=theElement.value;
  numero = dni.substr(0,dni.length-1);
  let = dni.substr(dni.length-1,1);
  numero = numero % 23;
  letra='TRWAGMYFPDXBNJZSQVHLCKET';
  letra=letra.substring(numero,numero+1);
  if (letra!=let){
		alert("El DNI introducido es erroneo");
		theElement.focus();
		return false;
	}else{
		return true;
	}
}