Question

Please Use JavaScript and P5 3) Password Protected Create an application with two input fields and...

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:

  • First field should be "Username"
  • Second field should be "Password"

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) ) {

}

Homework Answers

Answer #1
<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>
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT