Foros del Web » Programando para Internet » Javascript »

ayuda con validaciones

Estas en el tema de ayuda con validaciones en el foro de Javascript en Foros del Web. E vuelto de nuevo a solicitar su ayuda estas ves es para que me den un ejemplo de codificación pues por más que consigo una ...
  #1 (permalink)  
Antiguo 25/06/2008, 18:55
 
Fecha de Ingreso: mayo-2008
Mensajes: 41
Antigüedad: 16 años
Puntos: 0
De acuerdo ayuda con validaciones

E vuelto de nuevo a solicitar su ayuda estas ves es para que me den un ejemplo de codificación pues por más que consigo una información no entiendo como se enlaza y eso por favor si me puede ayudar un ejemplo simple es mi programa

<html>
<head>
<title>Formulario usuario</title>
<style type="text/css">
<!--
.Estilo1 {color: #000066}
-->
</style>
</head>

<body>

<img src="../logo2.bmp" alt="logo">
<form name="form1" method="post" action="..\acciones\accionesusuario.asp">
<table width="353" align="center">
<tr>
<td colspan="2" align="center"><h1 class="Estilo1">Formulario de Usuario </h1></td>
</tr>
<tr>
<td colspan="2"><span class="Estilo1"></span></td>
</tr>
<tr>
<td width="124"><h4 class="Estilo1"><em>Rut</em></h4></td>
<td width="217"><span class="Estilo1">
<label>
<input name="rut" type="text" id="rut">
<br>
</label>
</span></td>
</tr>
<tr>
<td><h4 class="Estilo1"><i>Nombre</i></h4></td>
<td><span class="Estilo1">
<label>
<input name="nombre" type="text" id="nombre">
<br>
</label>
</span></td>
</tr>
<tr>
<td><h4 class="Estilo1"><i>Apellido Paterno </i></h4></td>
<td><span class="Estilo1">
<label>
<input name="apellidopaterno" type="text" id="apellidopaterno">
<br>
</label>
</span></td>
</tr>
<tr>
<td><h4 class="Estilo1"><em>Apellido Materno </em></h4></td>
<td><span class="Estilo1">
<label>
<input name="apellidomaterno" type="text" id="apellidomaterno">
<br>
</label>
</span></td>
</tr>
<tr>
<td><h4 class="Estilo1"><em>Servicio</em></h4></td>
<td><span class="Estilo1">
<label>
<input name="servicio" type="text" id="servicio">
<br>
</label>
</span></td>
</tr>
<tr>
<td><h4 class="Estilo1"><em>Centro costo </em></h4></td> <td><span class="Estilo1">
<label>
<input name="ccosto" type="text" id="ccosto">
<br>
</label>
</span></td>
</tr>
<tr>
<td><h4 class="Estilo1"><i>Telefono </i></h4></td>
<td><span class="Estilo1">
<label>
<input name="telefono" type="text" id="telefono">
<br>
</label>
</span></td>
</tr>
<tr>
<td><h4 class="Estilo1"><i>Cargo</i></h4></td>
<td><span class="Estilo1">
<label>
<input name="cargo" type="text" id="cargo">
<br>
</label>
</span></td>
</tr>
<tr>
<td><span class="Estilo1"></span></td>
<td><span class="Estilo1"></span></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Crear/Modificar" name="crear" >
<input type="submit" value="Elimina" name="Elimina">
<input type="reset" value="Restablecer" name="boton" /></td>
</tr>
</table></form></body></html>
bueno considero que lo mas importante es la validacion de rut (ceular chilena) y ccosto (que solo es numero y entero):'(
  #2 (permalink)  
Antiguo 25/06/2008, 19:47
Avatar de JuanRAPerez
Colaborador
 
Fecha de Ingreso: octubre-2003
Mensajes: 2.393
Antigüedad: 20 años, 6 meses
Puntos: 27
Respuesta: ayuda con validaciones

q tipo de validación de el lado de el cliente o de el lado de el server????
__________________
JuanRa Pérez
San Salvador, El Salvador
  #3 (permalink)  
Antiguo 25/06/2008, 19:51
 
Fecha de Ingreso: mayo-2008
Mensajes: 41
Antigüedad: 16 años
Puntos: 0
Respuesta: ayuda con validaciones

disculpa se me olvido nombrar eso es del lado del cliente
  #4 (permalink)  
Antiguo 25/06/2008, 19:56
Avatar de AlZuwaga
Colaborador
 
Fecha de Ingreso: febrero-2001
Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 23 años, 2 meses
Puntos: 535
Respuesta: ayuda con validaciones

ok, pussy , entonces nos vamos para el foro Javascript.

un saludo (y otro para JuanRAPerez)
__________________
...___...
  #5 (permalink)  
Antiguo 25/06/2008, 22:15
 
Fecha de Ingreso: mayo-2008
Mensajes: 41
Antigüedad: 16 años
Puntos: 0
Respuesta: ayuda con validaciones

bueno solucione mi poblemita gracia, esto codigo espero que alguien le sirva de base, un ejemplo de formulario es : ami me cumplio mi objetivo

<html>
<head>
<title>Formulario Otros Dispositivo</title>
<style type="text/css">
<!--
.Estilo1 {color: #000066}
-->
</style>
<script>
function validar(formulario)
{
if (formulario.serie.value.length < 4)
{
alert("Escriba por lo menos 4 caracteres en el campo \"Serie\".");
formulario.serie.focus();
return (false);
}
var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ0123456789" + "abcdefghijklmnñopqrstuvwxyzáéíóú0123456789 ";
var checkStr = formulario.serie.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Escriba sólo letras en el campo \"Serie\".");
formulario.serie.focus();
return (false);
}
if (formulario.nus.value.length < 4)
{
alert("Escriba por lo menos 4 caracteres en el campo \"Nus\".");
formulario.nus.focus();
return (false);
}
var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ0123456789" + "abcdefghijklmnñopqrstuvwxyzáéíóú0123456789 ";
var checkStr = formulario.nus.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Escriba sólo letras en el campo \"Nus\".");
formulario.nus.focus();
return (false);
}
if (formulario.caracteristica.value.length < 4)
{
alert("Escriba por lo menos 4 caracteres en el campo \"Caracteristica\".");
formulario.caracteristica.focus();
return (false);
}
var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ0123456789" + "abcdefghijklmnñopqrstuvwxyzáéíóú0123456789 ";
var checkStr = formulario.caracteristica.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Escriba sólo letras en el campo \"Caracteristica\".");
formulario.caracteristica.focus();
return (false);
}
if (formulario.funcion.value.length < 4)
{
alert("Escriba por lo menos 4 caracteres en el campo \"Funcion\".");
formulario.funcion.focus();
return (false);
}
var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ0123456789" + "abcdefghijklmnñopqrstuvwxyzáéíóú0123456789 ";
var checkStr = formulario.funcion.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Escriba sólo letras en el campo \"Funcion\".");
formulario.funcion.focus();
return (false);
}
}
</script>

</head>

<body>
<form method = "POST" name = "registro" onSubmit = "return validar(this)" action = "..\acciones\accionesotros.asp">

<img src="../logo2.bmp" alt="logo">
<table width="356" align="center">
<tr>
<td colspan="2" align="center"><h1 class="Estilo1">Formulario de Otros Dispositivo </h1></td>
</tr>
<tr>
<td colspan="2"><span class="Estilo1"></span></td>
</tr>
<tr>
<td width="106"><h4 class="Estilo1"><i>Serie</i></h4></td>
<td width="238"><span class="Estilo1">
<label>
<input name="serie" type="text" id="serie">
<br>
</label>
</span></td>
</tr>
<tr>
<td><h4 class="Estilo1"><i>Nus</i></h4></td>
<td><span class="Estilo1">
<label>
<input name="nus" type="text" id="nus">
</label>
</span></td>
</tr>
<tr>
<td><h4 class="Estilo1">&nbsp;</h4>
<h4 class="Estilo1"><i>Caracteristica</i></h4>
<p class="Estilo1">&nbsp;</p></td>
<td><span class="Estilo1">
<label>
<textarea name="caracteristica" rows="3" id="caracteristica"></textarea>
</label></span></td>
</tr>
<tr>
<td><h4 class="Estilo1"><i>Funcion </i></h4></td>
<td><span class="Estilo1">
<label>
<textarea name="funcion" rows="3" id="funcion"></textarea>
</label>
</span></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Crear/Modificar" name="crear">
&nbsp;&nbsp;
<input type="submit" value="Elimina" name="Elimina">
&nbsp;&nbsp;
<input type="reset" value="Restablecer" name="boton" /></td>
</tr>
</table>
</form>
</body>
</html>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:19.