jQuery validation Example

Hello guys, Bushan here, Welcome back to B2 Tech. If we are creating any kind of web application and having a forms in the web application is very very common. In such applications, validating a form fields plays a major role, we can validate the form fields in two ways, one is client side and another one is server side. Today in this article, let’s discuss the client side validation using jQuery validator.




First thing first, In order to work with jQuery validator first we need jQuery core library because the jQuery validator is dependent on jQuery. So first let’s include jQuery core library CDN just before closing the </body> tag.
after the jQuery core library, include the jQuery validator CDN
If you are using bootstrap then include the bootstrap core library CDN
then finally include our customised js file which holds the jQuery validation



Make sure to include bootstrap core css file in the <head> section if you are using bootstrap
jQuery validate function takes two properties, one is rules and another one is messages, inside the rules we will specify the form/input elements name and respective validation like required. In the messages, respective error messages will specify.

Find the complete source code below

register.html




register.js

That’s it now open the register.html click the submit button without entering anything, it will display the error messages.



Below is the quick demo of the example

You can download the example from the below links,

Love this post?


Help me to buy a cup of coffee/Support us by donating.
All the donations will be going to the website maintenance/improvement.

Pay Now



About the author

Bushan Sirgur

Well, I am Bushan Sirgur from Banglore, India. Currently, I am working as a Software Developer in a Service Base Company. I am interested in JAVA/J2EE, Angular 2, JavaScript, jQuery, MongoDB.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *