Email and Confirm Email ID validation while enter the confirm email id.


I have to validate my email id and confirm email id when i am entering the character-wise it should validate and show the result.

You can achieve this by using simple jquery and javascript

Html Code


<input type="text" id="txtEmail" />

<input type="text" id="txtEmail2" />

<span id="confirmMessage" class="confirmMessage"></span>


And jquery/javascript code


$(function () {

    $("#txtEmail2").keyup(function () {

        var email = $("#txtEmail").val();

        var confirmEmail = $("#txtEmail2").val();

        var altMessage = document.getElementById('confirmMessage');

        if (email != confirmEmail) {

            $(this).css('background-color', '#CD5C5C');

   = "#CD5C5C";

            altMessage.innerHTML = "Email Do Not Match!"

            return false;

        } else {

            $(this).css('background-color', '#009900');

   = "#009900";

            altMessage.innerHTML = "Email Match!"


        return true;