function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false;}
else {return true}
}
}


function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false;}
else {return true;}
}
}

function validar_fecha(field)
{
with (field)
{
var Fecha= new String(value)	// Crea un string
var RealFecha= new Date()	// Para sacar la fecha de hoy
// Cadena Año
var Ano= new String(Fecha.substring(Fecha.lastIndexOf("-")+1,Fecha.length))
// Cadena Mes
var Mes= new String(Fecha.substring(Fecha.indexOf("-")+1,Fecha.lastIndexOf("-")))
// Cadena Día
var Dia= new String(Fecha.substring(0,Fecha.indexOf("-")))

// Valido el año
if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1900)
	{
    alert('A\u00f1o inv\u00e1lido')
	return false
	}
// Valido el Mes
if (isNaN(Mes) || parseFloat(Mes)<1 || parseFloat(Mes)>12)
	{
	alert('Mes inv\u00e1lido')
	return false
	}
// Valido el Dia
if (isNaN(Dia) || parseInt(Dia)<1 || parseInt(Dia)>31)
	{
	alert('D\u00eda inv\u00e1lido')
	return false
	}
if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2)
	{
	if (Mes==2 && Dia > 28 || Dia>30) 
		{
		alert('D\u00eda inv\u00e1lido')
		return false
		}
	}	
}
}

function validate_form(thisform)
{
with (thisform)
{
if (validate_email(email,"La direcci\u00F3n de correo no es v\u00E1lida")==false)
  {email.focus();return false;}
  
if (validate_required(nombre,"Debe rellenar el nombre")==false)
  {nombre.focus();return false;}
  
if (validate_required(asunto,"Debe indicar un asunto")==false)
  {asunto.focus();return false;}    
}
}


function validate_xacobeo10(thisform)
{
with (thisform)
{ 
if (validate_required(DNI,"Debe rellenar el Documento de Identidad")==false)
  {DNI.focus();return false;}
  
if (validate_required(nombre,"Debe rellenar el Nombre")==false)
  {nombre.focus();return false;}
  
if (validate_required(apellidos,"Debe rellenar el campo Apellidos")==false)
  {apellidos.focus();return false;}
  
if (validate_required(telefono,"Debe rellenar el Tel\u00e9fono:")==false)
  {telefono.focus();return false;}
 
if (validate_email(email,"La direcci\u00F3n de correo no es v\u00E1lida")==false)
  {email.focus();return false;}
 
if (validate_required(fecha_nacimiento,"Introduzca la fecha en formato DD/MM/AAAA")==false)
  {fecha_nacimiento.focus();return false;}
  
if (validar_fecha(fecha_nacimiento)==false)
  {fecha_nacimiento.focus();return false;}

if (validate_required(cantidad,"Debe indicar la cantidad que ha ingresado en el Banco")==false)
  {cantidad.focus();return false;}
}
}  
 
