
Ayuda Para validar Campos vacios en PHP
Publicado por claudio (3 intervenciones) el 15/03/2011 07:07:45
Hola amigso els cuento que estoy trabajando con PHP, Adobe Dreamweaver y Mysql, y lo que necesito es validar los campos vacios.
Espero sus respuestas.
Esta es la estructura del form:
<form action="alta.php" method="post">
<table width="89%" align="center" cellpadding="0" cellspacing="2">
<tr>
<th width="32%" align="right" scope="col">Ingrese nombre<span style="font-weight: bold; color: #FF0000">:</span></th>
<th width="68%" align="left" scope="col"><input name="nombre" type="text" id="nombre" size="30" maxlength="30" onkeypress="return validar(event)" /></th>
</tr>
<tr>
<th width="32%" align="right" scope="col">Ingrese apellido<span style="color: #FF0000; font-weight: bold">:</span></th>
<th width="68%" align="left" scope="col"><input name="apellido" type="text" id="apellido" size="30" maxlength="30" onkeypress="return validar(event)" /></th>
</tr>
<tr>
<th align="right" scope="col"> fecha de nacimiento<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="f_nacimiento" type="text" id="f_nacimiento4" size="10" maxlength="10" /></th>
</tr>
<tr>
<th align="right" scope="col">DNI<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="dni" type="text" id="dni" size="10" maxlength="9" onkeypress="return validar2(event)" /></th>
</tr>
<tr>
<th align="right" scope="col">Ingrese direccion<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="direccion" type="text" id="direccion3" size="30" maxlength="30" /></th>
</tr>
<tr>
<th align="right" scope="col">Ingrese telefono<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="telefono" type="text" id="telefono5" size="10" maxlength="11" onkeypress="return validar2(event)" /></th>
</tr>
<tr>
<th align="right" scope="col">fecha de alta<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="f_alta" type="text" id="f_alta4" size="10" maxlength="10" /></th>
</tr>
<tr>
<th align="right" scope="col">Antigüedad<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="antigüedad" type="text" id="antigüedad" size="10" maxlength="10" /></th>
</tr>
<tr>
<th align="right" scope="col">Turno<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="turno" type="text" id="turno" size="10" maxlength="10" onkeypress="return validar3(event)" /></th>
</tr>
<tr>
<th align="right" scope="col">Inasistencia<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="inasistencia" type="text" id="inasistencia" size="10" maxlength="10" onkeypress="return validar2(event)" /></th>
</tr>
<tr>
<td align="right" valign="top"><strong>Seleccione categoria<span style="color: #FF0000; font-weight: bold">:</span></strong></td>
<td><select name="categoria" id="categoria">
<option value="1" selected="selected">ADMINISTRATIVO A</option>
<option value="2">ADMINISTRATIVO B</option>
<option value="3">ENCARGADO DEPOSITO</option>
<option value="4">MECANICO</option>
<option value="5">CHOFER</option>
</select></td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle"><div align="right">
<input type="submit" value="Registrar" />
</div></td>
</tr>
</table>
</form>
***********************************************************************************************
Saludos!
Espero sus respuestas.
Esta es la estructura del form:
<form action="alta.php" method="post">
<table width="89%" align="center" cellpadding="0" cellspacing="2">
<tr>
<th width="32%" align="right" scope="col">Ingrese nombre<span style="font-weight: bold; color: #FF0000">:</span></th>
<th width="68%" align="left" scope="col"><input name="nombre" type="text" id="nombre" size="30" maxlength="30" onkeypress="return validar(event)" /></th>
</tr>
<tr>
<th width="32%" align="right" scope="col">Ingrese apellido<span style="color: #FF0000; font-weight: bold">:</span></th>
<th width="68%" align="left" scope="col"><input name="apellido" type="text" id="apellido" size="30" maxlength="30" onkeypress="return validar(event)" /></th>
</tr>
<tr>
<th align="right" scope="col"> fecha de nacimiento<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="f_nacimiento" type="text" id="f_nacimiento4" size="10" maxlength="10" /></th>
</tr>
<tr>
<th align="right" scope="col">DNI<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="dni" type="text" id="dni" size="10" maxlength="9" onkeypress="return validar2(event)" /></th>
</tr>
<tr>
<th align="right" scope="col">Ingrese direccion<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="direccion" type="text" id="direccion3" size="30" maxlength="30" /></th>
</tr>
<tr>
<th align="right" scope="col">Ingrese telefono<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="telefono" type="text" id="telefono5" size="10" maxlength="11" onkeypress="return validar2(event)" /></th>
</tr>
<tr>
<th align="right" scope="col">fecha de alta<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="f_alta" type="text" id="f_alta4" size="10" maxlength="10" /></th>
</tr>
<tr>
<th align="right" scope="col">Antigüedad<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="antigüedad" type="text" id="antigüedad" size="10" maxlength="10" /></th>
</tr>
<tr>
<th align="right" scope="col">Turno<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="turno" type="text" id="turno" size="10" maxlength="10" onkeypress="return validar3(event)" /></th>
</tr>
<tr>
<th align="right" scope="col">Inasistencia<span style="color: #FF0000; font-weight: bold">:</span></th>
<th align="left" scope="col"><input name="inasistencia" type="text" id="inasistencia" size="10" maxlength="10" onkeypress="return validar2(event)" /></th>
</tr>
<tr>
<td align="right" valign="top"><strong>Seleccione categoria<span style="color: #FF0000; font-weight: bold">:</span></strong></td>
<td><select name="categoria" id="categoria">
<option value="1" selected="selected">ADMINISTRATIVO A</option>
<option value="2">ADMINISTRATIVO B</option>
<option value="3">ENCARGADO DEPOSITO</option>
<option value="4">MECANICO</option>
<option value="5">CHOFER</option>
</select></td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle"><div align="right">
<input type="submit" value="Registrar" />
</div></td>
</tr>
</table>
</form>
***********************************************************************************************
Saludos!
Valora esta pregunta


0