Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Terrible Password Protection Revamped</title>
- <meta charset = "utf-8"/>
- <script>
- function userRepeat() {
- var valid = false;
- var usernames = ["darth", "luke", "leia", "han", "chewy", "r2" ];
- var passwords = ["vader", "sky", "princess", "ego", "carpet", "d2"];
- var userName = document.getElementById("usernames").value;
- var userPass = document.getElementById("passwords").value;
- for ( i = 0 ; i < usernames.length ; i++ ) {
- if ( userName == usernames [i] && userPass == passwords [i] ) {
- valid = true;
- break;
- }
- }
- if ( valid == true ) {
- document.getElementById("info").innerHTML =("Welcome " + usernames [i] + " " + passwords [i]);
- }
- else {
- document.getElementById("info").innerHTML =("Invalid Password");
- }
- }
- </script>
- </head>
- <body>
- <form>
- <input type = "text" id = "usernames"/> Username<br/>
- <input type = "password" id = "passwords"/> Password<br/> <div id="info"></div>
- <input type = "button" value = "Login" onClick = "userRepeat()"/>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement