UNPKG

formvalidation

Version:

The best jQuery plugin to validate form fields. Support Bootstrap, Foundation, Pure, SemanticUI, UIKit and custom frameworks

111 lines (100 loc) 5.84 kB
<!DOCTYPE html> <html> <head> <title>FormValidation demo</title> <link rel="stylesheet" href="../vendor/bootstrap/css/bootstrap.css"/> <link rel="stylesheet" href="../dist/css/formValidation.css"/> <script type="text/javascript" src="../vendor/jquery/jquery.min.js"></script> <script type="text/javascript" src="../vendor/bootstrap/js/bootstrap.min.js"></script> <script type="text/javascript" src="../dist/js/formValidation.js"></script> <script type="text/javascript" src="../dist/js/framework/bootstrap.js"></script> </head> <body> <div class="container"> <div class="row"> <!-- form: --> <section> <div class="col-lg-8 col-lg-offset-2"> <div class="page-header"> <h2>Sign up</h2> </div> <form id="defaultForm" method="post" class="form-horizontal" action="target.php" data-fv-message="This value is not valid" data-fv-icon-valid="glyphicon glyphicon-ok" data-fv-icon-invalid="glyphicon glyphicon-remove" data-fv-icon-validating="glyphicon glyphicon-refresh"> <div class="form-group"> <label class="col-lg-3 control-label">Full name</label> <div class="col-lg-4"> <input type="text" class="form-control" name="firstName" placeholder="First name" data-fv-trigger="keyup" required data-fv-notempty-message="The first name is required and cannot be empty" /> </div> <div class="col-lg-4"> <input type="text" class="form-control" name="lastName" placeholder="Last name" required data-fv-trigger="blur" data-fv-notempty-message="The last name is required and cannot be empty" /> </div> </div> <div class="form-group"> <label class="col-lg-3 control-label">Username</label> <div class="col-lg-5"> <input type="text" class="form-control" name="username" data-fv-trigger="blur" data-fv-message="The username is not valid" required data-fv-notempty-message="The username is required and cannot be empty" pattern="[a-zA-Z0-9_\.]+" data-fv-regexp-message="The username can only consist of alphabetical, number, dot and underscore" minlength="5" data-fv-stringlength-message="The username must have at least 5 characters" /> </div> </div> <div class="form-group"> <label class="col-lg-3 control-label">Email address</label> <div class="col-lg-5"> <input class="form-control" name="email" type="email" required data-fv-emailaddress-message="The input is not a valid email address" /> </div> </div> <div class="form-group"> <label class="col-lg-3 control-label">Website</label> <div class="col-lg-5"> <input class="form-control" name="website" type="url" required data-fv-uri-message="The input is not a valid website address" /> </div> </div> <div class="form-group"> <label class="col-lg-3 control-label">Fav color</label> <div class="col-lg-3"> <input class="form-control" name="color" type="color" required data-fv-color-message="The input is not a valid color code" /> </div> </div> <div class="form-group"> <label class="col-lg-3 control-label">Age</label> <div class="col-lg-2"> <input type="number" class="form-control" name="age" step="1" min="10" data-fv-greaterthan-inclusive="false" data-fv-greaterthan-message="The input must be greater than or equal to 10" max="100" data-fv-lessthan-inclusive="true" data-fv-lessthan-message="The input must be less than 100" /> <!--<input type="range" class="form-control" name="age" required min="10" max="100" data-fv-between-message="The input must be between 10 and 100" />--> </div> </div> <div class="form-group"> <label class="col-lg-3 control-label">Bio</label> <div class="col-lg-5"> <textarea class="form-control" name="bio" rows="10" data-fv-stringlength data-fv-stringlength-max="100" data-fv-stringlength-message="The bio must be less than 100 characters long"></textarea> </div> </div> <div class="form-group"> <div class="col-lg-9 col-lg-offset-3"> <button type="submit" class="btn btn-primary">Sign up</button> </div> </div> </form> </div> </section> <!-- :form --> </div> </div> <script type="text/javascript"> $(document).ready(function() { $('#defaultForm').formValidation(); }); </script> </body> </html>