jQuery Form Validator Script

Today, We want to share with you jQuery Form Validator Script.In this post we will show you simple jquery form validation example, hear for jquery form validation without plugin we will give you demo and example for implement.In this post, we will learn about registration form validation using jquery validator with an example.

jQuery Form Validator Script

There are the Following The simple About jquery form validation tutorial Full Information With Example and source code.

As I will cover this Post with live Working example to develop jquery form validation demo with source code, so the some major files and Directory structures for this example is following below.

Step 1: Include jQuery library

At first we need to include jQuery Latest library file.

Read Also:  jquery form validation without plugin

<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.js'></script>

Step 2: JavaScript/jQuery Source Code:

This file All the Data contains the following JavaScript/jQuery Source codes.

$(document).ready(function() {
    $("#memberFrm").validate({
        rules: {
            name: "required",
            email: {
                required: true,
                email: true
            },
            phone: {
                required: true,
                number: true
            },
            url: {
                required: false,
                url: true
            },
            username: {
                required: true,
                minlength: 6
            },
            password: {
                required: true,
                minlength: 6
            },
            confirm_password: {
                required: true,
                minlength: 6,
                equalTo: "#password"
            },
            agree: "required"
        },
        messages: {
            name: "Please enter your name",
            email: "Please enter a valid email address",
            phone: {
                required: "Please enter your phone number",
                number: "Please enter only numeric value"
            },
            url: {
                url: "Please enter valid url"
            },
            username: {
                required: "Please enter a username",
                minlength: "Your username must consist of at least 6 characters"
            },
            password: {
                required: "Please provide a password",
                minlength: "Your password must be at least 6 characters long"
            },
            confirm_password: {
                required: "Please provide a password",
                minlength: "Your password must be at least 6 characters long",
                equalTo: "Please enter the same password as above"
            },
            agree: "Please accept our policy"
        }
    });
});

Step 3: HTML Source Code:

This file contains the following HTML Markup Source codes.

Read Also:  Redirect page after delay using Vuejs

<form class="memberFrm" id="memberFrm" method="post" action="">
<p>
<label for="name">Name</label>
<input id="name" name="name" type="text">
</p>
<p>
<label for="email">E-Mail</label>
<input id="email" type="email" name="email">
</p>
<p>
<label for="phone">Phone</label>
<input id="phone" type="phone" name="phone">
</p>
<p>
<label for="url">URL</label>
<input id="url" type="url" name="url">
</p>
<p>
<label for="username">Username</label>
<input id="username" name="username" type="text">
</p>
<p>
<label for="password">Password</label>
<input id="password" name="password" type="password">
</p>
<p>
<label for="confirm_password">Confirm password</label>
<input id="confirm_password" name="confirm_password" type="password">
</p>
<p>
<label for="agree">Please agree to our policy</label>
<input type="checkbox" class="checkbox" id="agree" name="agree">
</p>
<p>
<input class="submit" type="submit" value="Submit">
</p>
</form>

Step 4: CSS Source Code

Following CSS Source codes are used for JQuery Form Validation using jQuery Validation Plugin Tutorial.

Read Also:  jquery validate Form Validation

.memberFrm{width: 400px;}
.memberFrm p {
    width: 100%;
}
.memberFrm label {
    width: 120px;
    color: #333;
    float: left;
}
input.error {
    border: 1px dotted red;
}
label.error{
    width: 100%;
    color: red;
    font-style: italic;
    margin-left: 120px;
    margin-bottom: 5px;
}
.memberFrm input.submit {
    margin-left: 120px;
}

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about form validation using jquery.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Format Phone Number using PHP
  2. Read Also:  Laravel 6 Create Custom Exception Error Page Example
  3. Read Also:  Get first and last value of ul li using jQuery
  4. Read Also:  Simple jQuery Form Validator validation
  5. Read Also:  User Registration and Login Authentication Code using angular 6
  6. Read Also:  Basic JQuery Form Validation Example
  7. Read Also:  How to get current user details in wordpress?
  8. Read Also:  Vuejs Double Click to inline editing vue Grid Component
  9. Read Also:  Advanced jQuery Tips Tricks and Solutions
  10. Read Also:  jQuery Ajax Image Upload without Page Refresh using PHP
CLOSEX