Whenever I click on my button it always says "please enter an email" even though there is text in the box. What am I doing wrong? I see that the ID for the password is incorrect. Right Now Im going to try and put the variables in the function.
var emailText = document.getElementById("Email").value;
var emailErrorMessage = document.getElementById("emailError");
var passwordText = document.getElementById("Password").value;
var passwordErrorMessage = document.getElementById("passwrodError");
var button = document.getElementById("submit");
function buttonValidation1(){
var text;
if (emailText === "") {
text = "Please enter an email";
}else{
text = "Email OK";
}
emailErrorMessage.innerHTML = text;
}
button.addEventListener("click", buttonValidation1);
<!DOCTYPE html>
<html>
<head>
</head>
<!--<body>
<p>Please input a number between 1 and 10:</p>
<input id="numb">
<button type="button" id="submit">Submit</button>
<p id="demo"></p> -->
<label>Email: </label>
<input type="text" id="Email"></input><span id="emailError"></span>
<br/> <br/>
<label>Password:</label>
<input type="password" id="Password"></input>
<spanid="passwordError"></span>
<br/>
<input type="submit" id="submit"></input>
<script src="Form.js"></script>
</body>
</html>