Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //index.html
- <div id="password-container">
- <div id="password-header">
- <h3>Please login to retrieve trip details or save a new trip</h3>
- </div>
- <form id="login" method="post" name="login">
- <label>Username :</label>
- <input type="text" name="username" id="username"/>
- <label>Password :</label>
- <input type="password" name="password" id="password"/>
- <input type="button" value="Login" id="submit" onclick="validate()"/>
- </form>
- </div>
- //login.js
- var testLogin = [
- {
- username: "Adrian",
- password: "password"
- },
- {
- username: "Max",
- password: "12345"
- },
- {
- username: "Ross",
- password: "testing"
- },
- {
- username: "Tom",
- password: "TheFace"
- }
- ]
- validate = function() {
- var username = document.getElementById("username").value
- var password = document.getElementById("password").value
- for (var i = 0; i < testLogin.length; i++) {
- if (username == testLogin[i].username && password == testLogin[i].password) {
- alert(username + " is logged in!")
- //window.location = where do we want to go?
- return;
- }
- }
- alert("incorrect username or password")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement