Solution:
<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");
}
23
else if(password==cpassword)
{
alert("You entered all the details ");
return false;
}
else
alert("Password Fields doesn't match");
}
</script>
<body>
<h2>Javascript Login Form Validation</h2>
<form id="form_id" name="myform">
<label>User Name :</label>
<input type="text" name="username" id="username"/></br></br>
<label>Password :</label>
<input type="password" name="password" id="password"/></br></br>
<label> Confirm Password :</label>
<input type="password" name="cpassword" id="cpassword"/></br></br>
<input type="button" value="Login" id="submit" onclick="validate()"/>
</form>
</body>
</html>
0 Comments