Advertisement
Guest User

Script

a guest
Nov 9th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Terrible Password Protection Revamped</title>
  5. <meta charset = "utf-8"/>
  6. <script>
  7.  
  8. function userRepeat() {
  9.  
  10. var valid = false;
  11.  
  12. var usernames = ["darth", "luke", "leia", "han", "chewy", "r2" ];
  13. var passwords = ["vader", "sky", "princess", "ego", "carpet", "d2"];
  14.  
  15. var userName = document.getElementById("usernames").value;
  16. var userPass = document.getElementById("passwords").value;
  17.  
  18. for ( i = 0 ; i < usernames.length ; i++ ) {
  19. if ( userName == usernames [i] && userPass == passwords [i] ) {
  20. valid = true;
  21. break;
  22. }
  23. }
  24.  
  25. if ( valid == true ) {
  26. document.getElementById("info").innerHTML =("Welcome " + usernames [i] + " " + passwords [i]);
  27. }
  28.  
  29. else {
  30. document.getElementById("info").innerHTML =("Invalid Password");
  31. }
  32.  
  33. }
  34. </script>
  35. </head>
  36. <body>
  37. <form>
  38.  
  39. <input type = "text" id = "usernames"/> Username<br/>
  40. <input type = "password" id = "passwords"/> Password<br/> <div id="info"></div>
  41. <input type = "button" value = "Login" onClick = "userRepeat()"/>
  42.  
  43. </form>
  44. </body>
  45. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement