<html>
<head>
<title>Javascript Login Form Validation</title>
<script>
function validate()
{
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
var cpassword = document.getElementById("cpassword").value;
if (username=="" || password=="" || cpassword=="" )
{
alert ("Fields Should not b empty");
//window.location = "success.html"; // Redirecting to other page.
//return false;
}
else if(password==cpassword)
{
alert("You entered all the details ");
return false;
}
else
alert("Password Fields doesn't match");
}
</script>
<body>
<div class="container">
<div class="main">
<h2>Javascript Login Form Validation</h2>
<form id="form_id" method="post" name="myform">
<label>User Name :</label>
<input type="text" name="username" id="username"/>
<label>Password :</label>
<input type="password" name="password" id="password"/>
<label> Confirm Password :</label>
<input type="password" name="cpassword" id="cpassword"/>
<input type="button" value="Login" id="submit" onclick="validate()"/>
</form>
</div>
</body>
</html>
JSconfirmPassword.html-
Displaying JSconfirmPassword.html.