Introduction
Client-side validation has been growing very fast due to its smaller impact on the server and you can reduce the round trips also by just filtering the required information in the form of form field validations.
There are many types of form fields which need a strict validation, not a single one, like field may allow you to only enter only the numbers, characters or both, but also it should require you to check that the field should not be empty having a specific format, either for example with password field it should have a check to contain special characters in field followed by single capital case and a more interesting password strength and length of password should be between 8 to 15 or like this. Would you guess you can do it in fewer lines of code? The answer to this question is NO.
Why because you cannot handle it; you require more time to code and use a lot of things to do the one kind of task to validate proper password standards. So here I want to introduce you to the best validation library which has a lot of more support for not only bootstrap but for Foundation, Pure, Semantic UI, UI Kit and lots more.
You can read more about the library and its documentation from here.
Before starting to implement read the getting started guide from here.
There are many forms of field validators in the market but what makes it best? Check out the features list.
Features of Form Validator
- Language packs included supporting multiple language packs.
- Glyph icons to validate input by using icons.
- Support for multiple frameworks bootstrap, Foundation, Semantic UI and lot of others more.
- Compatible with HTML5 Input types
- Compatible with Modern Browsers.
- Supports error message of type tooltip, message and lot of other ways to check validity.
- Over 51 built-in validators for different form fields.
- having add-ons like multiple languages and re-captcha support
This is all the features it supports, now let's move on to use it in web application.
Step 1:
For every JQuery Library, it is necessary to first include scripts file into the application and reference it on the page. First, make a choice from the supported frameworks and select the one you are working with and include it. For tutorial purposes, I am using bootstrap here. Firstly, add the following basic required jquery and Twitter bootstrap script to the head section of the page.
Note: Form validation requires jquery version => 1.9.1
Step 2:
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
- <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" />
- <script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
Add bootstrap validator scripts to the head section just below to the firstly added scripts.
- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-validator/0.5.3/css/bootstrapValidator.css"></script>
- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-validator/0.5.3/js/bootstrapValidator.min.js"></script>
I am using the CDN files here you may download scripts and follow the instructions in getting started panel to integrate with the best of your criteria.
Step 3:
Let’s build the form which can be validated through the bootstrap validator. I am using a signup form for this demo as it contains lots of things to cover.
- <form id="SignupForm" method="post" class="form-horizontal">
- <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" /> </div>
- </div>
- <div class="form-group"> <label class="col-lg-3 control-label">Email address</label>
- <div class="col-lg-5"> <input type="text" class="form-control" name="email" /> </div>
- </div>
- <div class="form-group"> <label class="col-lg-3 control-label">Password</label>
- <div class="col-lg-5"> <input type="password" class="form-control" name="password" /> </div>
- </div>
- <div class="form-group"> <label class="col-lg-3 control-label">Retype password</label>
- <div class="col-lg-5"> <input type="password" class="form-control" name="confirmPassword" /> </div>
- </div>
- <div class="form-group"> <label class="col-lg-3 control-label" id="captchasignup"></label>
- <div class="col-lg-2"> <input type="text" class="form-control" name="captcha" /> </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>
UI View looks like this after adding form and applying bootstrap.



Ashwini TandePosted Mar 18, 2019, 2:27 AM
It does not work when we use masterpage.. How to use with masterpage?
Bhuvanesh MohankumarPosted Apr 30, 2016, 3:08 PM
Good one...
Rahul Kumar SaxenaPosted Apr 24, 2016, 12:21 PM
Good One
Humayun Kabir MamunPosted Apr 24, 2016, 12:40 AM
Nice...
Bhuvanesh MohankumarPosted Apr 23, 2016, 6:23 PM
Good
Shaili DashoraPosted Apr 23, 2016, 6:48 AM
Nice one
Debasis SahaPosted Apr 23, 2016, 6:27 AM
Nice One..
Gowtham RajamanickamPosted Apr 23, 2016, 12:01 AM
good one
NitinPosted Apr 22, 2016, 11:40 PM
Nice
Sr KarthigaPosted Apr 22, 2016, 8:59 PM
good one
Vignesh ManiPosted Apr 22, 2016, 5:32 PM
Good
Ankur MistryPosted Apr 22, 2016, 1:49 PM
Good one
Michael GriffithsPosted Apr 22, 2016, 12:57 PM
Nice