// JavaScript Document
function validacion(formulario) {
    var adress=/^([0-9\s\+\-]|[a-z]|[A-Z]|á|é|í|ó|ú|ñ|ü|\s|\.|-)+$/
	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 LOAN_TYPE
	if(!er_nombre.test(formulario.LOAN_TYPE.value)) { 
		alert('Content of the field Loan Type not valid.')
		return false
	}   	
   	//comprueba campo de LOAN_AMOUNT
	if(!er_telefono.test(formulario.LOAN_AMOUNT.value)) { 
		alert('Content of the field Your Loan Amount not valid.')
		return false
	}   	
	//comprueba campo de BORROWER_NAME
	if(!er_nombre.test(formulario.BORROWER_NAME.value)) { 
		alert('Content of the field Your Borrowers Name not valid.')
		return false
	} 
	

	//comprueba campo de EMAIL
	if(!er_email.test(formulario.email.value)) { 
		alert('Content of the field Email  not valid.')
		return false
	} 
	//comprueba campo de Confirm Email Address
	
	if(formulario.EMAIL.value!=formulario.CONFIRM_EMAIL.value){
	alert('Content of the field Confirm Email Address  not valid.')
		return false
	}
	//comprueba campo de PROPERTY_ADDRESS
	if(!adress.test(formulario.PROPERTY_ADDRESS.value)) { 
	    
		alert('Content of the field Your Address not valid.')
		return false
	} 
	
	
	//comprueba campo de PROPERTY_CITY
	if(!er_nombre.test(formulario.PROPERTY_CITY.value)) { 
		alert('Content of the field Your City not valid.')
		return false
	} 
	//comprueba campo de PROPERTY_STATE
	if(!er_nombre.test(formulario.PROPERTY_STATE.value)) { 
		alert('Content of the field Your State not valid.')
		return false
	} 
	
}

