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

function validar_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_telefono(field,alerttxt) 
{
with (field)       
{
stripped = value.replace(/[\(\)\.\-\ ]/g, '');
   if (isNaN(parseInt(stripped))) 
     {alert(alerttxt);return false;}
    else {return true; }
}
}



function validate_form(thisform)
{
with (thisform)
{
	
if (validate_required(dia,"Seleccione un día!")==false) {dia.focus();dia.style.background = 'Yellow';return false;}	else dia.style.background = 'white'; 
if (validate_required(mes,"Seleccione un mes!")==false)
  {mes.focus();mes.style.background = 'Yellow';return false;}
  else mes.style.background = 'white'; 
if (validate_required(anyo,"Seleccione un año!")==false)
  {anyo.focus();anyo.style.background = 'Yellow';return false;}
  else anyo.style.background = 'white'; 
 if (validate_required(hora,"Seleccione una hora!")==false)
  {hora.focus();hora.style.background = 'Yellow';return false;}
  else hora.style.background = 'white'; 
if (validate_required(minuto,"Seleccione un minuto!")==false)
  {anyo.focus();anyo.style.background = 'Yellow';return false;}
  else minuto.style.background = 'white';

if (validate_required(correo,"Introduzca su correo electrónico!")==false)
  {correo.focus();correo.style.background = 'Yellow';return false;}

else if (validar_email(correo,"Correo electrónico incorrecto!")==false)
  {correo.focus();correo.style.background = 'Yellow';return false;}
    
else correo.style.background = 'white'; if (validate_required(nombre,"Introduzca su nombre!")==false)
  {nombre.focus();nombre.style.background = 'Yellow';return false;}
  
else nombre.style.background = 'white'; if (validate_required(telefono,"Introduzca su teléfono!")==false)
  {telefono.focus();telefono.style.background = 'Yellow';return false;}
  else if (validar_telefono(telefono,"Teléfono incorrecto nº!")==false)
  {telefono.focus();telefono.style.background = 'Yellow';return false;}
else telefono.style.background = 'white'; 


}
}