Compare validation using Java Script

April 06, 2015 0 Comments

<!DOCTYPE html>
    <title>encode and decode</title>
    <script type="text/javascript" >
        function validation() {

            var firstvalue = document.getElementById('first');
             var secondvalue = document.getElementById('second');
             if (firstvalue.value != secondvalue.value) {
                alert("Password not match");


<h1>Example of compare field validation control</h1>

Password<input type="password" name="gt" value="" id="first" /><br />
Re-type<input type="password" name="gt" value="" id="second" />
<button onclick="validation();">perform validation</button>


Code generate the following output

Compare validation in Java Script

Jacob Lefore

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google