Advertisement
angeldp

opos2008

Apr 11th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2.   <head>
  3.     <title>Boton</title>
  4.     <style type="text/css">
  5. a:link, a:visited, a:active {   color:#666666;  text-decoration:none; }
  6. a:hover {   color:#333333;  text-decoration:none;   }
  7. .asterisco{          color:red;       }
  8. th {border:none;}
  9. td { border: 1px solid black;}
  10. input[type="text"],input[type="password"]{border:none;}
  11.     </style>
  12.     <script type="text/javascript">
  13. function verificaCampos() {
  14. // Creamos variables para los campos a verificar
  15. nombre = document.getElementById("nombre");
  16. dni = document.getElementById("dni");
  17. passwd1 = document.getElementById("pass1");
  18. passwd2 = document.getElementById("pass2");
  19. //Comprueba que el nombre no esté vacío
  20.     if (nombre.value.length == 0)  {  
  21. alert("Tiene que escribir su nombre");
  22.         nombre.focus();
  23.         return (false); }
  24. // NÚMEROS, comprueba que el dni solo tiene números
  25. if (isNaN(dni.value) == true) {
  26.         alert ("el dni tiene que ser solo numérico");
  27.         dni.value ="";
  28.         dni.focus();
  29.         return (false); }
  30. if (dni.value.length < 7 || dni.value.length > 8) {
  31.             alert("Escriba entre 7 y 8 números en el campo \"DNI\".");
  32.         dni.value="";
  33.         dni.focus();
  34.             return (false);  }
  35. //Comprueba que el campo clave no este vacio
  36. if (passwd1.value.length == 0) {  
  37. alert("Tiene que escribir su clave") ;
  38.         passwd1.focus();
  39.         return (false); }
  40. //Para que compare si las claves son iguales
  41. if (passwd1.value != passwd2.value) {      
  42. alert("Las dos claves son distintas") ;
  43.         passwd2.value="";
  44.         passwd2.focus();
  45.         return (false);  }
  46.     return (true);
  47.     }
  48. </script>
  49. </head>
  50. <body>
  51. <form action="p1.php" method="post" name="formulario" onsubmit="return verificaCampos()">
  52.         <table align=center>
  53.         <tr>
  54. <th> Nombre:&nbsp;<span class="asterisco">*</span>&nbsp; </th>
  55.                 <td colspan=2><input type="text" value="" name="nombre" id="nombre" size="60"></td>
  56. </tr>
  57.         <tr>
  58. <th> Apellidos: </th>
  59.                 <td colspan=2><input type="text" value="" name="apellidos" size="60" ></td>
  60. </tr>
  61.         <tr>
  62. <th>  DNI:&nbsp;<span class="asterisco">*</span>&nbsp; </th>
  63.                 <td style="width:12em;"><input type="text" value="" name="dni" id="dni" ></td>
  64. </tr>
  65.         <tr>
  66. <th> Clave:&nbsp;<span class="asterisco">*</span>&nbsp; </th>
  67.                 <td><input type="password" value="" name="pass1" id="pass1" ></td>
  68. </tr>
  69.         <tr>
  70. <th> Repite la clave: </th>
  71.                 <td> <input type="password" value="" name="pass2" id="pass2" ></td>
  72. </tr>
  73.         <tr>
  74. <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>
  75. </tr>
  76.         <tr>
  77. <th colspan=3 align="center"><hr> <a href="http://www.misitioweb.com">Visita mi Sitio Web</a> </th>
  78. </tr>
  79. </table>
  80. </form>
  81. </body>
  82. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement