Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/08/2005, 10:06
Avatar de mauricio2004
mauricio2004
 
Fecha de Ingreso: marzo-2004
Mensajes: 264
Antigüedad: 20 años, 5 meses
Puntos: 0
Problemas con validar al enviar un formulario con una imagen

Hola como estan???

tengo el siguiente problema

tengo un formulario y con una funcion validar que es la siguiente
Código:
			function valida(theForm)
			{
				if ( theForm.codigo.value == "" )
				{
					alert("EL producto debe tener un código de producto.");
					focus(theForm.codigo.value);
					return (false);
				}
				if ( theForm.nombre.value == "" )
				{
					alert("El producto debe contener un nombre de producto.");
					focus(theForm.nombre.value);
					return (false);
				}
				if ( theForm.descripcion.value == "" )
				{
					alert("La descripción debe ser completada.");
					focus(theForm.descripcion.value);
					return (false);
				}
				if ( theForm.precio.value == "" )
				{
					alert("Debe poner algun precio al producto.");
					focus(theForm.precio.value);
					return (false);
				}
								if ( theForm.stock.value == "" )
				{
					alert("Por favor indiquenos el Stock Actual.");
					focus(theForm.stock.value);
					return (false);
				}
				return (true);

			}

el tipo funcion y tengo el siguiente formulario

Código HTML:
<form action="/store/administracion/p_modificar.php3" method="POST" enctype="multipart/form-data" name="form" target="principal" onSubmit="return valida(this)">
  <input type=hidden name=arrabal value=0>
  <table width="90%" border="1" cellspacing="0" cellpadding="2" align="center" bordercolor="#CCCCCC">
    <tr> 
      <td width="50%">Codigo del Producto</td>
      <td width="50%"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="70%"> <font size="2"> 
              <input type=text name=codigo size=20 maxlength="12" value="1">
              </font></td>
            <td width="30%"><font color="#999999">[Ej. 001]</font></td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td width="50%">Nombre del Producto</td>
      <td width="50%"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="70%"> <font size="2"> 
               <input type=text name=nombre size=20 maxlength="250" value="1">
              </font></td>
            <td width="30%"><font color="#999999">[Ej. Lapiz Bic]</font></td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td width="50%">Familia (si corresponde)</td>
      <td width="50%"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="70%"> <font size="2"> <select NAME=id_familia>
<option VALUE=none selected>Seleccione familia...</option>
<option VALUE="11">Enterprice Licence</option>
<option VALUE="13">Pequeña y Mediana Empresa</option>
<option VALUE="10">Usuarios Caseros</option>
<option VALUE="12">Empresa</option>
</select>
 </font></td>
            <td width="30%">&nbsp;</td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td width="50%">Descripci&oacute;n Corta</td>
      <td width="50%"><font size="2"> 
       <textarea name="descripcion" rows="3" cols="20">11</textarea>
        </font></td>
    </tr>
    <tr> 
      <td width="50%">Descripci&oacute;n Completa</td>
      <td width="50%">
       <textarea name="texto" rows="10" cols="45" ><P>1</P></textarea>
</td>
    </tr>
    <tr> 
      <td width="50%">Precio Normal</td>
      <td width="50%"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="70%"> $ <font size="2"> 
                <input type=text name=precio size=18 maxlength="10" value="1" onChange="cambiatodo(document.form.rangos.value,this); imprimetabla()">
              </font></td>
            <td width="30%"><font color="#999999">[Ej. 1990]</font></td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td width="50%">Stock Actual</td>
      <td width="50%"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="70%"> <font size="2"> 
               <input type=text name=stock size=6 maxlength="10" value="1">
              </font></td>
            <td width="30%"><font color="#999999">[Ej. 123]</font></td>
          </tr>
        </table></td>
    </tr>
    <tr>
      <td colspan="2">Cantidad de Rangos de Precio
	       <select name="rangos" id="rangos" onChange="envia();">
                    <OPTION>Seleccione</OPTION>
                    <option value="1" selected>1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="8">8</option>
          <option value="9">9</option>
          <option value="10">10</option>
          <option value="11">11</option>
          <option value="12">12</option>
          <option value="13">13</option>
          <option value="14">14</option>
        </select></td>
    </tr>
    <tr> 
      <td width="50%">&nbsp;</td>
      <td width="50%"><font face="Arial, Helvetica, sans-serif" size="2">
		<a href="javascript:document.form.submit();window.close();"><img src="AccionImages/b_modificar.gif" width="100" height="24" border="0"></a>
		<input type="hidden" name="id_producto" value="60">
					<input name="elegir" type="hidden" id="elegir" value="Modificar Producto">
                    <input name="modificar" type="hidden" id="modificar" value="Modificar Producto">
                       
       </font></td>
    </tr>
  </table>
</form> 
Notece que el que envia el formulario es una imagen, y la funcion validar no me esta pescando

pero cuando le pongo un objeto submit que es el boton que envia el formulario este si funciona


NO se que esta pasando si alguien me podria ayudar

Saludos

Mauricio