Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Boton</title>
- <style type="text/css">
- a:link, a:visited, a:active { color:#666666; text-decoration:none; }
- a:hover { color:#333333; text-decoration:none; }
- .asterisco{ color:red; }
- th {border:none;}
- td { border: 1px solid black;}
- input[type="text"],input[type="password"]{border:none;}
- </style>
- <script type="text/javascript">
- function verificaCampos() {
- // Creamos variables para los campos a verificar
- nombre = document.getElementById("nombre");
- dni = document.getElementById("dni");
- passwd1 = document.getElementById("pass1");
- passwd2 = document.getElementById("pass2");
- //Comprueba que el nombre no esté vacío
- if (nombre.value.length == 0) {
- alert("Tiene que escribir su nombre");
- nombre.focus();
- return (false); }
- // NÚMEROS, comprueba que el dni solo tiene números
- if (isNaN(dni.value) == true) {
- alert ("el dni tiene que ser solo numérico");
- dni.value ="";
- dni.focus();
- return (false); }
- if (dni.value.length < 7 || dni.value.length > 8) {
- alert("Escriba entre 7 y 8 números en el campo \"DNI\".");
- dni.value="";
- dni.focus();
- return (false); }
- //Comprueba que el campo clave no este vacio
- if (passwd1.value.length == 0) {
- alert("Tiene que escribir su clave") ;
- passwd1.focus();
- return (false); }
- //Para que compare si las claves son iguales
- if (passwd1.value != passwd2.value) {
- alert("Las dos claves son distintas") ;
- passwd2.value="";
- passwd2.focus();
- return (false); }
- return (true);
- }
- </script>
- </head>
- <body>
- <form action="p1.php" method="post" name="formulario" onsubmit="return verificaCampos()">
- <table align=center>
- <tr>
- <th> Nombre: <span class="asterisco">*</span> </th>
- <td colspan=2><input type="text" value="" name="nombre" id="nombre" size="60"></td>
- </tr>
- <tr>
- <th> Apellidos: </th>
- <td colspan=2><input type="text" value="" name="apellidos" size="60" ></td>
- </tr>
- <tr>
- <th> DNI: <span class="asterisco">*</span> </th>
- <td style="width:12em;"><input type="text" value="" name="dni" id="dni" ></td>
- </tr>
- <tr>
- <th> Clave: <span class="asterisco">*</span> </th>
- <td><input type="password" value="" name="pass1" id="pass1" ></td>
- </tr>
- <tr>
- <th> Repite la clave: </th>
- <td> <input type="password" value="" name="pass2" id="pass2" ></td>
- </tr>
- <tr>
- <th colspan=3 align="center"> <br><input style="margin-right:8em;" type="submit" name="enviar" value="Enviar" ><input type="reset" name="borrar" value="Borrar"></th>
- </tr>
- <tr>
- <th colspan=3 align="center"><hr> <a href="http://www.misitioweb.com">Visita mi Sitio Web</a> </th>
- </tr>
- </table>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement