Email Validation Using Jquery

Kailash Singh

Email Validation Using Jquery

Published Feb 14,2021 by Kailash Singh

0 Comment     1168 Views    

In this tutorial, we are providing you, how to create create email validation using JQuery.


How to use it:

We’re going to use the jQuery Validation Plugin to validate our form. The basic principle of this plugin is to specify validation rules and error messages for HTML elements in JavaScript.


Step 1: Include Bootstrap & jQuery Link .

<link rel="stylesheet" href="">

 <!--Here is JQuery Link -->
<script src=""></script>


Step 2: Include the jQuery Validation Plugin.

<script src=""></script>


Step 3: Create the HTML Form.

In this form, we are creating a name of the form, so that we can validate the form with the help of this name.

Eg: <form name="emailform">

<form name="emailform">

  <div class="form-group">

    <label for="pwd">Email:</label>
    <input type="text" class="form-control" name="email" placeholder="Enter your email">
    <button type="submit" class="btn btn-primary">Save</button>



Step 4: Create the Validation Rules.

            rules: {  
                  email: {
                         required: true,                             
                         email: true,
                         emailfull: true,
                  messages: {
                             email: {
                                required: "Email is required",
                                email: "Please enter a valid email address",
              submitHandler: function(form) {                                


      $.validator.addMethod("emailfull", function(value, element) {
            var pattern = new RegExp(/(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*")@((?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)$)|\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$/i);
                return this.optional(element) || pattern.test(value);
               }, "Please enter valid email address!"); 



Step5: Create Error Message Style In Head Tag.

<style type="text/css">
      color: red;
      font-size: 15px;
      font-weight: 400;


Comments ( 0 )