
	  function validarCampos(){
		  
		document.contacto.NombreContacto.value = document.contacto.NombreContacto.value.replace (/^\s*|\s*$/g,"")
        if (document.contacto.NombreContacto.value.length==0) { 
       	  alert("Debe indicar su nombre") 
       	  document.contacto.NombreContacto.focus() 
          return false; 
    	}
	
		document.contacto.ApellidosContacto.value = document.contacto.ApellidosContacto.value.replace (/^\s*|\s*$/g,"")
	    if (document.contacto.ApellidosContacto.value.length==0) { 
       	  alert("Debe indicar sus apellidos") 
       	  document.contacto.ApellidosContacto.focus() 
       	  return false; 
	    } 

		document.contacto.Correo.value = document.contacto.Correo.value.replace (/^\s*|\s*$/g,"")
	    if (document.contacto.Correo.value.length==0) { 
       	  alert("No ha introducido la dirección de correo electrónico") 
       	  document.contacto.Correo.focus() 
       	  return false; 
	    }
	    else {
		  if (!comprobarCorreo(document.contacto.Correo.value)) {
			return false;
		  }
	    }
		
		document.contacto.Tel.value = document.contacto.Tel.value.replace (/^\s*|\s*$/g,"")
		if (document.contacto.Tel.value.length!=0) {
		  if (!comprobarTelefono(document.contacto.Tel.value)) {
			alert("Debe indicar el número de teléfono con 9 cifras")
			document.contacto.Tel.focus()
			return false;
		  }
		}


		document.contacto.Telefax.value = document.contacto.Telefax.value.replace (/^\s*|\s*$/g,"")
		if (document.contacto.Telefax.value.length!=0) {
		  if (!comprobarTelefono(document.contacto.Telefax.value)) {
			alert("Debe indicar el número de fax con 9 cifras")
			document.contacto.Telefax.focus()
			return false;
		  }
		}
		
		document.contacto.DirecciónPostal.value = document.contacto.DirecciónPostal.value.replace (/^\s*|\s*$/g,"")
	    if (document.fot.DirecciónPostal.value.length>100){ 
          alert("El texto introducido en Dirección Postal supera los 100 caracteres") 
          document.fot.DirecciónPostal.focus() 
          return false; 
	    }
		
		document.contacto.Comentarios.value = document.contacto.Comentarios.value.replace (/^\s*|\s*$/g,"")
	    if (document.contacto.Comentarios.value.length==0){ 
          alert("Debe incluir su comentario") 
          document.contacto.Comentarios.focus() 
          return false; 
	    }
	 
	    if (document.contacto.Comentarios.value.length>250){ 
          alert("El texto introducido en Comentarios supera los 250 caracteres") 
          document.contacto.Comentarios.focus() 
          return false; 
	    }
		  return true;
	  } 

	  function comprobarCorreo(cadena) {
	    var formato = /[^\w^@^\.^-]+/gi
		if (formato.test(cadena)) {
     	  alert('La dirección de correo electrónico que ha introducido "'+ cadena + '" contiene caracteres extraños')
       	  document.contacto.Correo.focus()
		}
		else {
     	  formato =/(^\w+)(@{1})([\w\.-]+$)/i
     	  if (formato.test(cadena)){
		    return true; 
		  }
     	  else {
  	        alert("La dirección de correo electrónico que ha introducido no es válida") 
       	    document.contacto.Correo.focus()
            return false;
		  }
     	} 
	  }


	  function comprobarTelefono(cadena) {
	    var formatofono = /[0-9]{9}/
     	  if (formatofono.test(cadena)){
		    return true; 
		  }
     	  else {
            return false;
		  }
     	} 


		function limpiaralentrar() {
			document.contacto.reset();
		}	  

/*-----------Contador de caracteres que faltan por escribir en un cuadro de texto-----------*/
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Written by Steve - http://jsmadeeasy.com/ -->
<!-- Ampliado por Pepe Munilla -->

<!--
function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    }
	else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    }
	else {
      return obj.style;
    }
  }
  return null;
}

//Contador de caracteres.
function Contar(entrada,salida,texto,caracteres,textofinal) {
  var entradaObj=getObject(entrada);
  var salidaObj=getObject(salida);
  var longitud=caracteres - entradaObj.value.length;
  if(longitud <= 0) {
    longitud=0;
    texto='<span class="fincaracteres"> '+textofinal+' </span>';
    entradaObj.value=entradaObj.value.substr(0,caracteres);
  }
  salidaObj.innerHTML = texto.replace("{CHAR}",longitud);
}