Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/09/2012, 06:51
Avatar de fermin3d
fermin3d
 
Fecha de Ingreso: octubre-2010
Ubicación: sevilla
Mensajes: 141
Antigüedad: 14 años, 5 meses
Puntos: 4
no hace la funcion

Hola amigos estoy practicando con javascritp y no se porque no me funciona este script espero me puedan ayudar gracias.

Código Javascript:
Ver original
  1. valor = document.getElementById("nombre").value;
  2. function validacion(){
  3. if ( valor == null || valor.length == 0 || /^\s+$/.test(valor) ){
  4.    
  5.    
  6.     alert('error');
  7.     return false;
  8.     }
  9. }
y el html
Código HTML:
Ver original
  1. <form action="enviar.php" method="" name="" onsubmit="return validacion()">
  2. <input type="text" name="nombre"  />
  3. <input type="submit" value="enviar" />
  4. </form>

Muchas gracias