VALIDAR FORMULARIOS JQUERY

ValidaciónJquery validity

Es un plugin en jquery que nos permite validar nestros formularios Web. Su instalación es muy sencilla, nos descargamos el plugin desde la Web , lo referenciamos en nuestra Web :

<link type="text/css" rel="Stylesheet" href="jquery.validity.css" />

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

Y creamos la siguiente función:

<script type="text/javascript">
    // Select all of the forms on the page (in this case the only one)
    // and call 'validity' on the result.
    $(function() { 
        $("form").validity(function() {
            
        });
    });
</script>
           
Las posibles validaciones son muy variadas:

$("form").validity(function() {
    $("#vehicles")                      // The first input:    
        .require()                          // Required:
        .match("number")                    // In the format of a number:
        .range(4, 12);                      // Between 4 and 12 (inclusively):
    
    $("#dob")                           // The second input:
        .require()                          // Required:
        .match("date")                      // In the format of a date:
        .lessThanOrEqualTo(new Date());     // In the past (less than or equal to today):
});

En su Web podemos encontrar numerosa documentación 


Etiquetas
jquery validar Formularios JQUERY plugin con jquery validity form jquery