Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/04/2009, 13:25
Avatar de hoberwilly
hoberwilly
 
Fecha de Ingreso: julio-2008
Ubicación: Lima - Perú
Mensajes: 769
Antigüedad: 16 años, 7 meses
Puntos: 2
Enviar datos no vacios...evento onsubmit

Muy buenas amigos, tengo el siguiente codigo el cual mi intencion es k valide el campo de texto "CANTIDAD", el cual permita enviar al formulario con datos (no vacio)...pero no me valida. En alguna parte estare errado?, quizas me puedan orientar.
Código php:
Ver original
  1. <!-- <html>
  2. <head>
  3. <title>CATALOGO ELLAS</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. <script type="text/javascript">  
  6. function vacio(valor){
  7.     if(valor.value==""){
  8.         alert("Tiene que ingresar una cantidad!");
  9.         valor.focus();
  10.         return false;
  11.     }
  12.     return true;
  13. }
  14. </script>
  15. </head>
  16. <body>
  17. <table>    
  18. <tr>
  19.     <td>
  20.     <table>
  21.     <form name="form" method="post" action="agregacarElla.php?<?php echo SID ?>" onSubmit="return vacio(this);">
  22.     <tr>
  23.     <td>
  24.       <input type="text" name="cantidad" value="<?php echo $cantidad ?>" size="2" maxlength='4' onKeypress="return acceptNumNumero(this)">par(es)
  25.       <input type="hidden" name="id" value="<?php echo $row['id']; ?>">
  26.       <input type="hidden" name="pagina" value="<?php echo $pag ?>">
  27.     </td>
  28.     <td>&nbsp;<input name="imageField" type="image" src="img/icono-compras.gif" width="31" height="28" border="0" alt="Agregar al Carrito"></td>
  29.     </tr>
  30.     </form>
  31.     </table>
  32.     </td>
  33. </tr>
  34. </table>
  35. </body>
  36. </html>
  37.  -->

Muchas gracias por sus respuestas,