Ver Mensaje Individual
  #6 (permalink)  
Antiguo 03/11/2004, 14:43
angsanchez
 
Fecha de Ingreso: octubre-2004
Ubicación: España
Mensajes: 894
Antigüedad: 19 años, 6 meses
Puntos: 3
Se me adelantó SiR, pero ahí va mi solución:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
function Validar(form){
if(form.nombre.value == ""){
alert("ERROR: Ingrese su(s) Nombre(s). "); form.nombre.focus(); return;
}
if(form.apellidos.value == ""){
alert("ERROR: Ingrese sus Apellidos. "); form.apellidos.focus(); return;
}

if(form.estado.selectedIndex==0){
alert("ERROR: Ingrese el Estado. "); form.estado.focus(); return;
}
if(form.ciudad.selectedIndex==0){
alert("ERROR: Ingrese la Ciudad. "); form.ciudad.focus(); return;
}

if (form.email.value.indexOf('@', 0) == -1 || form.email.value.indexOf('.', 0) == -1){
alert("ERROR: Ingrese y/o dirección de E-mail inválida. "); form.email.focus(); return;
}
if(!validaNumeros(form.telefono.value)){
alert("ERROR: Ingrese su teléfono solo numeros. "); form.telefono.focus(); return;
}
if(!validaNumeros(form.ci.value)){
alert("ERROR: Ingrese su CI solo numeros. "); form.ci.focus(); return;
}

form.submit();
}

function validaNumeros(tx) {
for (i=0;i<tx.length;i++) {
var codi = tx.charCodeAt(i)
if ( codi<48 || codi>57 ) {
return false
}
}
if (tx!='') return true
else return false
}

</script>
</head>
<body>

<table width="100%" border="0" cellpadding="0" cellspacing="3">
<form name="myForm" action="" method="post">
<tr>
<td class="TextForm" align="right"><b>Nombres:</b></td>
<td><input type="text" name="nombre" size="30"></td>
</tr>
<tr>
<td class="TextForm" align="right"><b>Apellidos:</b></td>
<td><input type="text" name="apellidos" size="30"></td>
</tr>
<tr>
<td class="TextForm" align="right"><b>Estado:</b></td>
<td>
<select name="estado">
<option value="0">Seleccione
<option value="1">Distrito capital
<option value="2">Miranda
<option value="3">Zulia
</select>
</td>
</tr>
<tr>
<td class="TextForm" align="right"><b>Ciudad:</b></td>
<td>
<select name="ciudad">
<option value="0">Seleccione
<option value="1">Caracas
<option value="2">Turin
</select>
</td>
</tr>
<tr>
<td class="TextForm" align="right"><b>Correo Electrónico:</b></td>
<td><input type="text" name="email" size="15"></td>
</tr>
<tr>
<td class="TextForm" align="right"><b>Teléfono:</b></td>
<td><input type="text" name="telefono" size="15"></td>
</tr>
<tr>
<td class="TextForm" align="right"><b>CI:</b></td>
<td><input type="text" name="ci" size="10"> </td>
</tr>
<tr>
<td valign="top" class="TextForm" align="right"><b>Comentarios:</b></td>
<td><textarea name="comentario" cols="30" rows="5"></textarea></td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="hidden" name="accion" value="enviar">
<input type="button" value=" Enviar " name="enviar" onClick="Validar(this.form)">
<input type="reset" value=" Borrar ">
</td>
</tr>
</form>
</table>

</body>
</html>