[Php-avanzado] validar con js

leandro saubiette saubietteleandro en gmail.com
Sab Jul 20 19:44:57 ART 2013


Buenas, tengo un formulario que no puedo validar mediante js comprobe las
rutas y estan bien definidas y el js teoricamente tmb aca lo paso

function validar ()
{
if(document.getElementById("nombre").value == null)
{
alert ("Debe ingresar un nombre valido");
return false;
}
 if((document.getElementById('apellido').value) == "" ||
(is_numeric(document.getElementById('apellido'))))
{
alert ="Debe ingresar un apellido valido";
return false;
}
 if(document.getElementById('dni').value == "")
{
alert ="Debe ingresar un dni valido valido";
return false;
}
 if(document.getElementById('domicilio').value == "")
{
alert ="Debe ingresar un domicilio valido";
return false;
}
 if((document.getElementById('mail').value) == "" ||
(is_numeric(document.getElementById('mail'))))
{
alert ="Debe ingresar un mail valido";
return false;
}
 if(document.getElementById('telefono').value == "")
{
alert ="Debe ingresar un telefono valido";
return false;
}
 return true;
}


todos los campos del formulario tienen un id y llamo a la funcion validar
en el evento onSubmit() en la etiqueta form de la siguiente manera <form
action="" method="post"  onsubmit="validar()"> lo que tmb me parece raro es
que no cargue el css. Aca paso el html del php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="X-UA-Compatible" content="IE=7" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title> Centro cultural Juana Azurduy</title>

<script type="text/javascript" src="/js/validarAsociado.js"></script>

<style type="text/css" media="all">
@import url("/css/style.css");
</style>

</head>

<body>

<div id="header">
<?php include '/header.php';?>
</div>


<form action="" method="post"  onsubmit="validar()">
 <label>Nombre: </label>
<input type="text" name="nombre" id="nombre"><br><br>
 <label>Apellido: </label>
<input type="text" name="apellido" id="apellido"><br><br>
 <label>DNI: </label>
<input type="text" name="dni" id="dni"><br><br>
 <label>Mail: </label>
<input type="text" name="mail" id="mail"><br><br>
 <label>Direccion: </label>
<input type="text" name="direccion" id="direccion"><br><br>
 <label>Telefono: </label>
<input type="text" name="telefono" id="telefono"><br><br>
 <label>Fecha de Nacimiento: </label>
<input type="text" name="fechaNac" id="fechaNac"><br><br>
 <select name="nivel">
<option value ='<?php echo $niveles['id'];?>'><?php echo
$niveles['nivel']?></option>
</select><br><br>
 <input type="submit" name="agregar" value="agregar "id="agregar">
</form>
<div id="footer">
<?php include '/footer.php';?>
</div>
</body>
</html>


Gracias por cualquier ayuda
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://www3.fi.mdp.edu.ar/pipermail/php-avanzado/attachments/20130720/da9bd5f5/attachment.html>


Más información sobre la lista de distribución Php-avanzado