cdiego

pre_VALIDACION 2

Jul 14th, 2012
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.58 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5.     <title>Validación</title>
  6.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
  7.     <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js" type="text/javascript"></script>
  8.     <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/localization/messages_es.js" type="text/javascript"></script>
  9.     <style>
  10.         #formulario{
  11.             width: 300px;
  12.             position: relative;
  13.             margin: auto;
  14.             padding: 10px;
  15.             background: #cecece;
  16.             -moz-border-radius: 10px;
  17.         }
  18.         #formulario input{
  19.             width: 200px;
  20.         }
  21.         label{
  22.             position: absolute;
  23.             color:#888;
  24.             font-weight: bold;
  25.             display: block;
  26.         }
  27.         label.valid{
  28.             display: inline;
  29.             margin-left: 10px;
  30.             padding:10px;
  31.             background: url("images/valid.gif") center left no-repeat;
  32.         }
  33.     </style>
  34.     <script>
  35.     $(document).ready(function(){
  36.         $("#formulario").validate({
  37.             rules:{
  38.                 nombre:{
  39.                     required:true
  40.                 },
  41.                 sitio:{
  42.                     required:true,
  43.                     url:true
  44.                 },
  45.                 correo:{
  46.                     required:true,
  47.                     email:true
  48.                 },
  49.                 clave:{
  50.                     required:true,
  51.                     minlength:6
  52.                 },
  53.                 clave2:{
  54.                     required:true,
  55.                     equalTo:"#clave"
  56.                 }
  57.             },
  58.             success:function(etiqueta){
  59.                 $(etiqueta).addClass("valid");
  60.             }
  61.         });
  62.     });
  63.     </script>
  64.    
  65. </head>
  66. <body>
  67. <form id="formulario">
  68.     <h2>Formulario de registro</h2>
  69.     <div>
  70.         <p>Nombre</p>
  71.         <input type="text" name="nombre" />
  72.     </div>
  73.     <div>
  74.         <p>Sitio web</p>
  75.         <input type="text" name="sitio" />
  76.     </div>
  77.     <div>
  78.         <p>Correo</p>
  79.         <input type="text" name="correo" />
  80.     </div>
  81.     <div>
  82.         <p>Clave</p>
  83.         <input type="password" name="clave" id="clave" />
  84.     </div>
  85.     <div>
  86.         <p>Repetir clave</p>
  87.         <input type="password" name="clave2" />
  88.     </div>
  89.     <div>
  90.         <br>
  91.         <input type="submit" value="Grabar" />
  92.     </div>
  93. </form>
  94. </body>
  95. </html>
Advertisement
Add Comment
Please, Sign In to add comment