// JavaScript Document
// JavaScript Document
function validacion(formulario) {
    
	var er_nombre = /^([a-z]|[A-Z]|á|é|í|ó|ú|ñ|ü|\s|\.|-)+$/			//letras, '.' y '-' o vacio
	var er_telefono = /^([0-9\s\+\-])+$/						//numeros, espacios, + o -
	//fechas, formato dd/mm/aaaa o d/m/aa
	var er_mes31dias = /^([1-3]0|[0-2][1-9]|31|[0-9])\/(1|01|3|03|5|05|7|07|8|08|10|12)\/(1999|20[0-1][0-9]|2020)$/
	var er_mes30dias = /^([1-3]0|[0-2][1-9]|[0-9])\/(4|04|6|06|9|09|11)\/(1999|20[0-1][0-9]|2020)$/
	var er_mes28dias = /^([1-2]0|[0-2][1-8]|[0-1]9|[0-9])\/(02|2)\/(1999|200[1-3]|200[5-7]|2009|201[0-1]|201[3-5]|201[7-9])$/
	var er_mes29dias = /^([1-2]0|[0-2][1-9]|[0-9])\/(02|2)\/(2000|2004|2008|2012|2016|2020)$/
	//direccion de correo electronico
	var er_email = /^(.+\@.+\..+)$/
	var x
   	
	//comprueba 50 caracteres maximo
	for(x = 1; x < 5; x++) {
		if (formulario.elements[x].value.length > 50) {
			alert('La lontitud máxima permitida para cualquier campo es de 10 caracteres.')
			return false
		}
	}   	
      	
	//comprueba campo de NAME
	if(!er_nombre.test(formulario.NAME.value)) { 
		alert('Content of the field Your Name not valid.')
		return false
	}   	
   	//comprueba campo de PURPOSE_OF_LOAN
	if(!er_nombre.test(formulario.PURPOSE_OF_LOAN.value)) { 
		alert('Content of the field Your Purpose of loan not valid.')
		return false
	}   	
	

	//comprueba campo de EMAIL
	if(!er_email.test(formulario.EMAIL.value)) { 
		alert('Content of the field Your Email  not valid.')
		return false
	} 
	//comprueba campo de Confirm Email EMAIL2
	
	if(formulario.EMAIL.value!=formulario.EMAIL2.value){
	alert('Content of the field Confirm Re-Type Email  not valid.')
		return false
	}
	//comprueba campo de HOME_PHONE
	if(!er_telefono.test(formulario.HOME_PHONE.value)) { 
	    
		alert('Content of the field Your Home Phone not valid.')
		return false
	} 
	//comprueba campo de WORK_PHONE
	if(!er_telefono.test(formulario.WORK_PHONE.value)) { 
		alert('Content of the field Your Work Phone not valid.')
		return false
	} 
	
	
	
}

