Please Use JavaScript and P5
3) Password Protected
Create an application with two input fields and one button.
When the button is clicked, verify the user has written these (exact) strings in the first and second field:
If the two fields match, update a DIV on the page with the text "Success" or else "Wrong information".
For this assignment: use only one if statement to to the check.
Remember you'll need to use the double-equals (==) to check for equality, and the double-ampersand to check if two things are true.
if( (oneThingIsTrue) && (anotherThingIsTrue) ) {
}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script>
function onsubmitclick() {
if (document.getElementById("username").value == "Username" && document.getElementById("password").value == "Password") {
document.getElementById("result").innerHTML = "Success";
} else {
document.getElementById("result").innerHTML = "Wrong Information";
}
}
</script>
</head>
<body>
<input type="text" id="username" placeholder="username">
<input type="password" id="password" placeholder="password">
<input type="button" name="button" value="submit" onclick="onsubmitclick()">
<div id="result"> </div>
</body>
</html>
Get Answers For Free
Most questions answered within 1 hours.