Thread: Resolved Login Form in Javascript
View Single Post
Old 11-13-2012, 11:40 AM   PM User | #1
adityavishnu
New to the CF scene

 
Join Date: Nov 2012
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
adityavishnu is an unknown quantity at this point
Login Form in Javascript

Hey guys i am trying to create a login form with html and javascript and everything is working except that i am not able to implement maximum attempts to this. It tried nested ifs and for too but didn't succeed.In the below code i am trying to implement maximum 3 attempts of wrong username or password.
Code:
<html>
<head>
<script type="text/javascript">
function login() { 
var u=document.getElementById("user").value;
var v=document.getElementById("pass").value;
var i=0;
if(i<3)
{
if (u=="admin" && v=="admin_12")
{alert("Welcome");}
else
{alert("Oops,Try Again");
i++;}}
else{alert("Maximum Attempts Over");}
}
</script>
</head>
<body>
<form>
<b>User Name </b><input type="text"  id="user">
<b>Password </b><input type="password"  maxlength="8" id="pass">
<p>
<input type="button" value="Login" onclick="login()">
</form>
</body>
</html>

Last edited by adityavishnu; 11-13-2012 at 04:13 PM..
adityavishnu is offline   Reply With Quote