![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
08/09/2003, 19:17
|
| | Fecha de Ingreso: abril-2003 Ubicación: El Salvador
Mensajes: 8
Antigüedad: 21 años, 9 meses Puntos: 0 | |
Lo mejor para hacer una validacion es desde el lado del usuario asi no cargamos el servidor con este trabajo y que mejor que con JavaScripts, ya que todo se hace desde el lado del usuario, te envio un scripts que a mi me funciona muy bien y es sensillo de imprementar, te recomiendo que lo pruebes primero asi como te lo envio para que entiendas como funciona y luego lo adaptas a tu necesidad espero te sirva.
<html>
<script language="JavaScript" type="text/javascript">
<!--
function checkform (form)
{
// ** CHECK-SEXO **
if (datos.sexo.value == "") {
alert( "POR FAVOR INTRODUZCA SU SEXO." );
datos.sexo.focus();
return false ;
}
// ** CHECK-NOMBRES **
if (datos.nombres.value == "") {
alert( "POR FAVOR INTRODUZCA SUS NOMBRES." );
datos.nombres.focus();
return false ;
}
// ** CHECK-APELLIDOS **
if (datos.apellidos.value == "") {
alert( "POR FAVOR INTRODUZCA SUS APELLIDOS." );
datos.apellidos.focus();
return false ;
}
// ** END **
return true ;
}
//-->
</script>
<body>
<form action="NONE" name="datos" method="post" >
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="50%" align="right">SEXO:</td>
<td width="50%" align="left"><input type="text" name="sexo" size="20"></td>
</tr>
<tr>
<td width="50%" align="right">NOMBRE:</td>
<td width="50%" align="left"><input type="text" name="nombres" size="20"></td>
</tr>
<tr>
<td width="50%" align="right">APELLIDOS: </td>
<td width="50%" align="left"><input type="text" name="apellidos" size="20"></td>
</tr>
</table>
<p align="center">
<input type="button" value="Enviar" onclick="return checkform(this);" >
</form>
</body>
</html> |