|   
			 
			
			
			
			
			
			
		     
			
				31/03/2011, 06:39
			
			
			     |  
      |    |    |    Fecha de Ingreso: marzo-2011  
						Mensajes: 12
					  Antigüedad: 14 años, 7 meses Puntos: 0     |        |  
  |      Respuesta: Validar un campo dinamico en formulario php        <html> 
<head> 
<title></title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<meta content="jquery, forumlario dinamico, timersys, tutorial" name="keywords"/>   
<style type="text/css"> 
.hide { 
	visibility: hidden; 
	display: none; 
}body { 
	background-image: url(); 
} 
.Estilo1 {font-family: Calibri} 
.Estilo3 { 
	font-family: Calibri; 
	color: #FFFFFF; 
} 
.Estilo4 {color: #FFFFFF} 
.Estilo6 {font-size: 10} 
.Estilo7 {font-size: 12px} 
body,td,th { 
	font-family: Calibri; 
	font-size: 12px;   
} 
.sel { 
	font-family: Calibri; 
	color: #000000; 
} 
</style>   
<script type="text/javascript" src="js/items_detalles.js" ></script> 
<script type="text/javascript" src="js/jquery.js"></script> 
<script type="text/javascript" src="js/jquery.validate.js"></script> 
<script type="text/javascript"> 
function validar(){   
var valor = document.getElementById("cantidad").value;     
		if(valor == null || valor.length == 0 || /^\s+$/.test(valor)){ 
			alert("Ingrese la cantidad de producto a solicitar"); 
			return false;			  			  				     }   
		else if(isNaN(valor)){ 
			alert("Ingrese la cantidad de producto (solo números)"); 
			return false; 
			} 
		else{ 
			alert("Su requisición sera impresa automaticamente"); 
			return true; 
			}     
				  }     
</script>  
</head>   
<body> 
<form id="formInscripcion" name="formInscripcion" action="envio22.php" method="POST" onSubmit="return validar()"> 
  <table width="478" border="0"> 
  <tr> 
    <td colspan="2" bgcolor="#666666" class="Estilo7"><div align="center" class="Estilo1"><span class="Estilo3"> Departamento Solicitante</span></div></td> 
    <td width="58" bgcolor="#666666" class="Estilo7"><div align="center"><span class="Estilo3">N° Req</span> </div></td>   
    <td width="56" bgcolor="#666666" class="Estilo7"><div align="center"><span class="Estilo1 Estilo4">Fecha</span></div></td> 
  </tr> 
  <tr> 
    <td width="70" bgcolor="#666666" class="Estilo7"><span class="Estilo3">Nombre</span></td> 
    <td width="276" class="Estilo7"><label>     
    </label>      <label> 
    <select class="sel" style="width:257px"  name="nom_dep" id="nom_dep" >   
            <option value = "ADMINISTRACION CC AYACUCHO">ADMINISTRACION CC AYACUCHO</option> 
            <option value = "VENTAS">VENTAS</option> 
            <option value = "VICE-PRESIDENCIA">VICE-PRESIDENCIA</option> 
          </select> 
    </label></td> 
    <td class="Estilo7"><input name="num_req" disabled="disabled" class="Estilo1" id="num_req" value="6750" size="8"/></td> 
    <td class="Estilo7"><input name="fecha" class="Estilo1" id="fecha" value="30/03/2011" size="8"/></td>   
  </tr>   
  <tr> 
    <td colspan="4" bgcolor="#666666" class="Estilo7"><div align="center" class="Estilo3">Información de Requisición </div></td> 
    </tr>     
  <tr> 
    <td bgcolor="#666666" class="Estilo7"><span class="Estilo1 Estilo4">Observación </span></td>   
    <td colspan="5" class="Estilo7"><input name="obs" class="Estilo1" value="" size="57"/></td> 
    </tr> 
</table> 
<span class="Estilo7"><br> 
<table width="497" border="0">   
<tr><td width="411" bgcolor="#666666" class="Estilo7"><div align="center" class="Estilo4"><span class="Estilo1">Descripción del Producto</span></div>  <div align="center" class="Estilo4"></div></td> 
  <td width="76" colspan="2" bgcolor="#666666" class="Estilo7"><div align="center" class="Estilo4"><span class="Estilo1">Cantidad</span></div>    <div align="center" class="Estilo4"></div></td> 
  </tr>   
<tr>       
  <td colspan="3" class="Estilo7"><label></label>    <label> 
   <div id="myDiv">  
     <div align="right"> 
       <select name="materiales[]" class="sel" style="width:414px"> 
                  <option value = "AMBIENTADOR">AMBIENTADOR</option> 
                  <option value = "PILAS AAA">PILAS AAA</option> 
                  <option value = "PILAS CR-123A">PILAS CR-123A</option>   
                  <option value = "SILICONE SPRAY ULTRA RAPIDO SQ">SILICONE SPRAY ULTRA RAPIDO SQ</option> 
                </select>   
      <input name="cantidadmateriales[]" size="8" id="cantidad">   
     </div> 
     <div class="error_form"></div></div> 
         </label></td> 
  </tr>   
<tr>   
  <td colspan="3" class="Estilo7"><div align="center">   
    <input type="submit" name="guardar" value="GUARDAR" id="guardar" style="BORDER: rgb(128,128,128) 1px solid; FONT-SIZE: 10pt; FONT-FAMILY: Calibri; BACKGROUND-COLOR: rgb(233,233,233); cursor:pointer" title="Guardar Requisición"/> 
    <!--<input type="submit" name="enviar" value="Enviar" />-->   
    <input type="button" name="detalles" id="detalles" value="AGREGAR" onClick="addFormLine('myDiv', 'div_1');" style="BORDER: rgb(128,128,128) 1px solid; FONT-SIZE: 10pt; FONT-FAMILY: Calibri; BACKGROUND-COLOR: rgb(233,233,233); cursor:pointer" title="Agregar producto adicional"/> 
  </div>   </td> </tr> 
</table>   
</form>   
</body> 
</html>   
   <div id="div_1" class="hide"> <select name="materiales[]" class="sel" style="width:414px" > 
            <option value = "AMBIENTADOR">AMBIENTADOR</option> 
            <option value = "PILAS AAA">PILAS AAA</option> 
            <option value = "PILAS CR-123A">PILAS CR-123A</option> 
            <option value = "SILICONE SPRAY ULTRA RAPIDO SQ">SILICONE SPRAY ULTRA RAPIDO SQ</option>   
          </select>   
    <input name="cantidadmateriales[]" size="8" id="cantidad"> 
 <div class="error_form"></div></div>           |