Created
January 12, 2017 17:05
-
-
Save dylanerichards/24cdb5626205486c270a15fdc3cb8f07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var header = document.getElementById("header") | |
var button = document.getElementById("login-button") | |
button.addEventListener("click", function() { | |
validateForm() | |
}) | |
function validateForm() { | |
if(checkPassword() == true && checkUsername() == true) { | |
header.innerHTML = "<h1>You're now logged in!</h1>" | |
} else { | |
alert("Incorrect!") | |
} | |
} | |
function checkPassword() { | |
var password = document.getElementById("password").value | |
if (password == "12345678") { | |
return true | |
} else { | |
return false | |
} | |
} | |
function checkUsername() { | |
var username = document.getElementById("username").value | |
var characters = username.split("") | |
var presence = characters.map(function(element) { | |
return Number.isInteger(parseInt(element)) | |
}) | |
if (presence.indexOf(true) !== -1) { | |
return true | |
} else { | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment