Answer to Question #328874 in HTML/JavaScript Web Application for Bylapati suresh kumar

Question #328874

In this CCBP Login Dynamic Web Application I can’t getting the above JS functionalities

  • When the submit is clicked and the value of the HTML input elements with id name is empty and password is not empty then the text content in the HTML paragraph elements with id nameErrMsg and resultMsg should have an error message and "Fill in the required details" respectively
  • When the submit is clicked and the value of the HTML input elements with id name is not empty and password is empty then the text content in the HTML paragraph elements with id passwordErrMsg and resultMsg should have an error message and "Fill in the required details" respectively
  • When the HTML button element with attribute type submit is clicked, if the values of the HTML input elements with ids name and password are empty then the text content in the HTML paragraph element with id resultMsg should be displayed as "Fill in the required details

this cases are not executed please help


1
Expert's answer
2022-04-15T16:35:07-0400
<!DOCTYPE html>
<html> 
<head>
<title>Hello html</title>
</head>
<body>
    <label for="Name">Name name:</label>
    <input type="text" id="Name" name="name" class="text"><br><br>
    <label for="Password">Password :</label>
    <input type="text" id="Password" name="password" class="text"><br><br>


    <button class="btn btn-primary" type="button">
        click
    </button>
</body>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
<script>
    $('.btn').click(function(){
        let inputs = $('.text');
        for (let i = 0; inputs.length; i++)
         if(inputs[i].value.length === 0)
          inputs[i].value = "Fill in the required details";
    });
</script>


</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