Professional Documents
Culture Documents
Validacion de Utilizando Comodines
Validacion de Utilizando Comodines
El siguiente ejercicio lohemos realizado deacuerdo a las necesidades que tiene una
pagina web al validar un formulario de envio de formulario para su servidor
Programacion en Javascript
es valido envía el formulario al servidor eso esla idea planeada.
<html>
<head>
<script>
function validarEntero(valor){
valor = parseInt(valor)
if (isNaN(valor)) {
return ""
}else{
return valor
function valida_envia(){
//valido el nombre
if (document.fvalida.nombre.value.length==0){
document.fvalida.nombre.focus()
return 0;
edad = document.fvalida.edad.value
edad = validarEntero(edad)
document.fvalida.edad.value=edad
if (edad==""){
document.fvalida.edad.focus()
return 0;
}else{
if (edad<18){
document.fvalida.edad.focus()
return 0;
}
2
[Seleccionar fecha]
//valido el interés
if (document.fvalida.interes.selectedIndex==0){
document.fvalida.interes.focus()
return 0;
email = document.fvalida.email.value
email = validarEntero(email)
document.fvalida.email.value=email
if(email==expresion)
else
alert("e-mail no valido");
alert("")
document.fvalida.submit();
</script>
</head>
<body>
3
[Seleccionar fecha]
<form name="fvalida">
<table>
<tr>
<td>Nombre: </td>
</tr>
<tr>
<td>Edad: </td>
</tr>
<tr>
<td>Interés:</td>
<td>
<select name=interes>
<option value="Elegir">Elegir
</select>
</td>
</tr>
<tr>
<td>Email:</td>
</tr>
<tr>
4
[Seleccionar fecha]
</tr>
</table>
</form>
</body>
</html>
El resultado es el siguiente:
Para el email:
5
[Seleccionar fecha]
Para el nombre:
6
[Seleccionar fecha]
Para la edad:
Para el interés:
7
[Seleccionar fecha]