Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <link rel="stylesheet" href="style.css">
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
- <script src="test.js"></script>
- <title>Generation X</title>
- </head>
- <body>
- <form method="post">
- <label for="username">Username:</label><input type="text" name="user_name" id="username"><br />
- <label for="password">Password:</label><input type="password" name="pass-word" id="password">
- <input type="submit" id="submitbutton" value="Access">
- </form>
- </body>
- </html>
- var userInfo = [
- { username: "admin", password: "test" }
- ];
- function addUser(username, password) {
- userInfo[userInfo.length + 1]["username"] = username;
- userInfo[userInfo.length + 1]["password"] = password;
- }
- $(document).ready(function() {
- $('#submitbutton').click(function() {
- var username = $('#username').val();
- var password = $('#password').val();
- for (i = 0; i < userInfo.length; i++) {
- if (username == '' || password == '') {
- alert("All fields are required!");
- }
- else if (username == userInfo[i]["username"]) {
- if (password == userInfo[i]["password"]) {
- alert("Welcome");
- }
- else {
- alert("You have entered an invalid password!");
- }
- }
- else {
- addUser(username, password);
- alert("Account created!");
- }
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement