          function mostrar_informacion(txt){            



            var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/                



            return b.test(txt)  



        } 

        //funcion para validar que el campo no este vacio



        function vacio(q) {  

           for ( i = 0; i < q.length; i++ ) {  

               if ( q.charAt(i) != " " ) {  

                       return true  

               }  

           }  

            return false  

        }


		

		//funcio que valida numero entero

		

		function isNum(q) {



for ( i = 0; i < q.length; i++ ) {

//con el for y la sentencia if( q.charAt(i) = " " ){... ..ya me queda lista para validar los espacios en blanco, de lo contrario:

valor = parseInt(q.charAt(i)); // me permite convertir letra por letra en numero y si no es un numero entonces no regresa nada

if (isNaN(valor)) {

return true

}

}

return false

}



        

		

		

		//funcio valida un textarea

		function validatextarea() {

		if (document.formmat.coment.value.length==0 ) {



             return false;

         }

           else return true;



          }

		  
		
//funcion que borra els missatges d'error
function hideAllErrors() {
document.getElementById("nameError").style.display = "none";
document.getElementById("tlfError").style.display = "none";
document.getElementById("tlfError2").style.display = "none";
document.getElementById("mailError").style.display = "none";
document.getElementById("mailError2").style.display = "none";
document.getElementById("comentError").style.display = "none";
  }
 //Fi funcion que borra els missatges d'error
 //Inicialitzo variables
           
			
			 
// Fi Inicialitzo variables
//funcion que me recoge cada input del formulario
        function validacion(formmat){  

		      if (vacio(formmat.nom.value) == false){

               
              hideAllErrors();

			  document.getElementById("nameError").style.display = "inline";
              document.getElementById("nom").select();
              document.getElementById("nom").focus();
 
              


                return false 

            } 
           
			

			 if (vacio(formmat.tlf.value) == false){

              hideAllErrors();

              document.getElementById("tlfError").style.display = "inline";
              document.getElementById("tlf").select();
              document.getElementById("tlf").focus();


                return false 





            } 

			if(isNaN(formmat.tlf.value)){

              hideAllErrors();
			  document.getElementById("tlfError2").style.display = "inline";
              document.getElementById("tlf").select();
              document.getElementById("tlf").focus();



                return false 



            } 
             if (vacio(formmat.email.value) == false){

               hideAllErrors();
              document.getElementById("mailError").style.display = "inline";
              document.getElementById("email").select();
              document.getElementById("email").focus();



                return false 

            } 
			if (mostrar_informacion(formmat.email.value) == false){


              hideAllErrors();
                document.getElementById("mailError2").style.display = "inline";
              document.getElementById("email").select();
              document.getElementById("email").focus();



                return false 

			}

           
			if (validatextarea(formmat.coment.value) == false){

               hideAllErrors();
                document.getElementById("comentError").style.display = "inline";
              document.getElementById("coment").select();
              document.getElementById("coment").focus();



                return false 



            }
           
			
			 return true

			

        }

       

  


