How would I repeat a block of code in Javascript? (asking users for a username and password) -
i want have repeat function around bit of javascript code:
<script language="javascript"> var usernamecheck="username"; var passcheck="password"; var username=prompt ('enter username',' '); var password=prompt ('enter password',' '); if (username+password==usernamecheck+passcheck) ; else {window.location="http://www.google.com";} </script>
i want bit of code repeat 3 times if user inputs incorrect username or password in.
i want inform user password or username have entered incorrect , tell them try again. when have had 3 tries sent webpage e.g."http://www.google.com" .
how this? (please help)
can't use loop?
for example:
<script language="javascript"> var usernamecheck="username"; var passcheck="password"; var username=prompt ('enter username',' '); var password=prompt ('enter password',' '); //create counter var var counter = 3; //next create loop loop 3 times if still credidentials //are incorrect send user google.com (var = 0; < counter; i++){ if { (username+password==usernamecheck+passcheck) ; //put in code terminate loop } else var username=prompt ('enter username',' '); var password=prompt ('enter password',' ');} } window.location="http://www.google.com"; </script>
i agree else not means of site protections, not familiar javascript language (i program in java) seems familiar enough.
also check logic else stated above
Comments
Post a Comment