Quote:
Originally Posted by Philip M
To be candid, if you cannot deduct 1 from a counter then you ought to give up programming and consider taking up underwater motorcycling instead.
Try counter --;
|
HaHA Some days I do feel like that packing it in

Ok I got it working so far with my counter and it works good for the 3 failed attempts, Howwever My problem now is that when I enter in a correct username and password lets such say on my second attempt its says that I have access but it also gives the counter message saying that i only have 1 attempt left aswel....hmmmmm
here is my code up to date...
<script language="javascript">
var counter = 3
function passuser(form)
{
if (form.user.value=="trevor" &&form.password.value=="hello")
{
window.alert("Hello sir")
location='http://www.google.com'
}
counter = counter - 1
if (counter ==2)
{
window.alert("Username or Password is incorrect - You have " +counter+ " tries left")
}
if (counter ==1)
{
window.alert("Username or Password is incorrect - You have " +counter+ " tries left")
}
if (counter ==0)
{
window.alert("Access Denied")
}
}
</script>
</head>
<body><center><br />
<form action="name" method="get">
<table width="300" height="200" border="1" cellpadding="5"cellspacing="5">
<tr>
<th colspan="2" scope="col"bgcolor="#6699FF"><center>LOGIN FORM</center></th>
</tr>
<tr>
<td width="120" align="center"> User Name</td>
<td width="140"><label>
<input type="text" name="user" id="user" />
</label></td>
</tr>
<tr>
<td align="center">Password</td>
<td><label>
<input type="password" name="password" id="password" />
</label></td>
</tr>
<tr>
<td align="center"><label>
<input type="reset" name="cmdClear" id="cmdClear" value="Reset" />
</label></td>
<td align="center"><label>
<input type="submit" name="enter" id="log" value="Login" onclick="passuser(this.form)" />
</label></td>
</tr>
</table>
</form>
</center>
</body>