Answer to Question #302694 in HTML/JavaScript Web Application for CHETHAN

Question #302694

Sign In Page

The goal of this coding exam is to quickly get you off the ground with Conversions and Conditional Statements.

Use the below reference image.

https://assets.ccbp.in/frontend/content/dynamic-webapps/signin-op.gif

HTML

<!DOCTYPE html>

<html>


<head></head>


<body>

  <p>Enter your Name</p>

  <input type="text" id="inputElement" />

  <p>Enter your Password</p>

  <input type="password" id="passwordElement" />

  <div>

    <button class="button" id="signInBtn" onclick="signIn()">Sign In</button>

  </div>

  <p id="messageText"></p>

</body>


</html>

CSS

.button {

  color: #ffffff;

  background-color: #0967d2;

  font-size: 14px;

  border-width: 0;

  border-radius: 4px;

  margin: 10px;

  padding: 10px;

}


1
Expert's answer
2022-02-25T10:29:09-0500
<!DOCTYPE html>
<html>
<head></head>
<body>
    <style>
        .button {
            color: #ffffff;
            background-color: #0967d2;
            font-size: 14px;
            border-width: 0;
            border-radius: 4px;
            margin: 10px;
            padding: 10px;
        }
    </style>
    <p>Enter your Name</p>
    <input type="text" id="inputElement" />
    <p>Enter your Password</p>
    <input type="password" id="passwordElement" />
    <div>
        <button class="button" id="signInBtn" onclick="signIn()">Sign In</button>
    </div>
    <p id="messageText"></p>
    <script>
        const name = document.querySelector('#inputElement'),
              password = document.querySelector('#passwordElement'),
              message = document.querySelector('#messageText');
        function signIn() {
            if (name.value) {
                if (password.value) {
                    message.innerHTML = 'Welcome';
                } else {
                    message.innerHTML = 'Please Enter Password'
                }
            } else {
                    message.innerHTML = 'Please Enter UserName'
            }
        }
    </script>
</body>
</html>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS