Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/07/2010, 05:15
popi
 
Fecha de Ingreso: abril-2008
Ubicación: BCN
Mensajes: 53
Antigüedad: 16 años
Puntos: 0
Error en ie al validar formulario - "Se requiere un objeto"

Buenos días,

Dispongo de un archivo js que me valida un formulario, de manera que cuando se entra un campo que esta vacio, debajo del input del campo, sale un mensaje del tipo "Debes rellenar campo X", todo me funciona a la perfección en todos los navegadores, pero en ie, aunque funciona, en la barra inferior me pone "Listo pero con errores en la página, me dice que se requiere un objeto.

No se muy bien a que se debe, haber si me podeis ayudar. El error me lo da en la línea de código:

Código:
 nom = document.getElementById("nom"). value;
Código:
function vacio(q) {  

           for ( i = 0; i < q.length; i++ ) {  

               if ( q.charAt(i) != " " ) {  

                       return true  

               }  

           }  

            return false  

        }

function hideAllErrors() {
document.getElementById("nameError").style.display = "none";
document.getElementById("mailError").style.display = "none";

  }

         nom = document.getElementById("nom"). value;
	 
         mail = document.getElementById("mail").value;
	
			
			 

        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.mail.value) == false){

               hideAllErrors();
              document.getElementById("mailError").style.display = "inline";
              document.getElementById("mail").select();
              document.getElementById("mail").focus();



                return false 

            } 
		
           
		
           
			
			 return true

			

        }

El formulario seria:

Código:
<form name="formmat"   method="post"  onsubmit="return validacion(this);" action="enviar.php" >
	<fieldset>
			
			<p>
				<label for="nom">Nombre</label><br />
           <input name="nom"  type="text" id="nom"   size="70" maxlength="70" />
			</p>
					   
      
	<div class="neteja"></div>
	
	  <div class="error" id="nameError"><span style="color:#CC3300;
">Camp obligatori:</span> Rellenar nombre</div>
	
          
      
	
	
	
           <p>
				<label for="mail">Email</label><br /> 
             <input name="mail"  type="text" id="mail" size="70" maxlength="70"   />
			 
        </p>
	<div class="neteja"></div>
    
		  <div class="error" id="mailError"><span style="color:#CC3300;
">Camp obligatori:</span> Rellenar campo Email</div>
		  	
	
	     

		  
		  
      </fieldset>

        
		   
	      <input type="submit" class="botoenviar" value="" />
		 
		
		</form>
Gracias y saludos