Diferencia entre revisiones de «Usuario:ManuelRomero/JavaScript/jquery/validate/solucionEJ4»

De WikiEducator
Saltar a: navegación, buscar
 
Línea 1: Línea 1:
 
[[Usuario:ManuelRomero/JavaScript/jquery/validate|<font size=5 color=red>VOLVER</font>]]
 
[[Usuario:ManuelRomero/JavaScript/jquery/validate|<font size=5 color=red>VOLVER</font>]]
*El evento jvalidate viene definido con un parámetro especial
+
<!--
*Este parámetro se conoce como objeto json
+
*Un objeto json es una pareja parámetro valor separado por : y encerrado entre llaves
+
'''''{parametro:valor}'''''
+
*Como ya hemos visto en teoría tenemos que dar valores al elemento '''''rules'''''
+
 
<source lang=html5>
 
<source lang=html5>
 
<!doctype html>
 
<!doctype html>
Línea 70: Línea 66:
  
 
</source>
 
</source>
 +
-->

Última revisión de 01:37 15 abr 2016

VOLVER

   <style>
       .important{color:red; font-weight:bold;}
       label{display:inline-block; width:200px;}
       input[type="submit"]{margin-left:200px;}
   </style>
   <script type="text/javascript" src="jquery-1.8.2.min.js"></script>
   <script type="text/javascript" src="jquery.validate.js"></script>

</head>

<body>

   <form id="formulario" novalidate action="accion.php" method="post">
           <label for="nombre">Nombre:
               *
           </label>
           <input type="text" id="nombre" name="nombre" />
           <label for="email">E-mail:
               *
           </label>
           <input type="email" id="email" name="email" />
           <label for="url">Url:</label>
           <input type="url" id="url" name="url" />
           <label for="comentarios">Comentarios:</label>
           <textarea id="comentarios" name="comentarios"></textarea>
           <input type="submit" value="Enviar" />
   </form>
   <script>
       $("#formulario").validate({
               onkeyup: false,
               onfocusout: false,
               onclick: false,
               rules: {
                   nombre: {
                       required: true,
                       minlength: 2
                   },
                   email: "required",
                   comentarios: "required"
               }
               });
   </script>

</body>

</html>

</source> -->