jQuery Form Validation Using Validate Engine

jQuery Form Validation Using Validate Engine

In this post, we are going to explain to you how to set up basic jQuery form validation using validate engine. Here is the full demonstration with form Here we are going to use a validation plugin to validate our HTML form You can specify validation rules and different error messages for your HTML form as per your requirement.

Here are the Steps for the Implementation of Validation

So, first of all, you have to include jQuery Engine. We need to include v1.x as the validation plugin which is only compatible with jQuery versions lower than 2.0.

  • You need to download it from jquery.com.
  • Also, you can download using NPM: $ npm install jquery@1.x –save-dev
  • You can download it using browser: $ bower install jquery#1.x –save-dev
  • Use a CDN: https://cdn.jsdelivr.net/jquery/1.12.4/jquery.min.js

Now please create new HTML file name is index.html and include jQuery min before closing body tag:

Here we have more detail about NPM if you don’t know what is NPM and how it work don’t hesitate. Please follow below link and go ahead.

  • Package Management for the Browser with Bower
  • A Beginner’s Guide to NPM — the Node Package Manager

1. Include jQuery Validation Plugin

Validation plugin play main and effective in validation because all logic are written inside it here we have steps how to download it.

  • You can download it from the plugin’s website.
  • Also, you can download it using Bower: $ bower install jQuery-validation
  • You can download it using NPM: $ npm install jQuery-validation
  • Use CDN methord https://cdn.jsdelivr.net/jquery.validation/1.15.1/jquery.validate.m

2. Include Plugins After jQuery Min JS

3. Create HTML Student Form

  • First Name
  • Last Name
  • Email ID
  • Password

Now lets create HTML form which include student information inputs.

Our html form is ready now make sure that please fill action attribute with your real path when your application is live because form is submitted to the correct destination

4. Create Styles for the Form

Now create new file name is style.css, and include it inside head section of your html file.

Now copy and paste below CSS code into style.css

5. Create the Validation Rules

Now finally we are reach to initialize the form validation plugin. Now create new folder name JS and create new file name is form-validation.js inside it and reference it. After script tag and then include it on your HTML page.

Copy and paste below code into the newly created file:

Conclusion:

Well done that’s it for today. I hope now you have a real idea of how to set up jQuery Form Validation Using Validate Engine. Please keep in your mind that this script doesn’t replace server-side validation. This is still possible for a corrupt user to bypass the validation rules.

You can also read this blog: How to Forcefully Download File in PHP

2 Comments, RSS

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

*

11 − 4 =