
<!--
/**
*  Válida la sintaxis del email
*
*  Comprobaciones :
*    - Mínimo de 5 caracteres
*    - Caracteres no permitidos : "+*|,\":<>[]{}`';()&$#% "
*    - Que la @ tenga algún caracter delante y alguno detrás
*    - Que exista '.' a partir del cuarto carácter (x@x.x)
*    - Que no acabe en '.'
*    - Que el punto esté detrás de la @
*/
function validamail(email){
   // Mínimo de 5 caracteres
  	if (email.length < 5)
   	return false
   // Cadena de caracteres no permitidos
    var iChars = "+*|,\":<>[]{}`';()&$#% ";	
   // Primero comprobamos que en el email no haya algún 
   // caracter no permitido
    var eLength = email.length;	
    for (var i=0; i < eLength; i++)	{		
    if (iChars.indexOf(email.charAt(i)) != -1)
    return false
   }	
    // Comprobamos que la @ tenga algún caracter delante y alguno detrás
    var atIndex = email.lastIndexOf("@");	
  	if(atIndex < 1 || (atIndex == eLength - 1))
   	return false
    // Comprobamos que exista '.' a partir del cuarto carácter, pero
    // que no acabé en '.'
  	var pIndex = email.lastIndexOf(".");	
   	if(pIndex < 3 || (pIndex == eLength - 1))	
   	return false;	
    // Por último, comprobamos que el punto esté detrás de la @
  	if(atIndex > pIndex)	
   	return false	
    return true
}
    
    
    
/*----------------------validar formulario------------------------*/
function ocultar_error()
{    
      var dverror=document.getElementById("texto_error")
      if (dverror.style.display=="block") {
        dverror.style.display="none"
      }
}
function validar() {
        var f = document.recomienda
        var dverror=document.getElementById("texto_error")
        if ( f.tunombre.value == "" ) {
         dverror.style.display="block"     
         f.tunombre.focus()
         return false;
       }
       if ( f.tuemail.value.length == 0 ) {
        dverror.style.display="block" 
        f.tuemail.focus()
        return false;
      	}
      if ( !validamail(f.tuemail.value) ) {
       dverror.style.display="block" 
       f.tuemail.focus()
       return false;
      }
      
      if ( f.nombreamigo.value == "" ) {
       dverror.style.display="block" 
       f.nombreamigo.focus()
       return false;
       }
      if ( f.emailamigo.value.length == 0 ) {
       dverror.style.display="block" 
       f.emailamigo.focus()
       return false;
      	}
      if ( !validamail(f.emailamigo.value) ) {
       dverror.style.display="block" 
       f.emailamigo.focus()
       return false;
      }

       return true;
      }

-->