Answer to Question #304015 in HTML/JavaScript Web Application for eranna

Question #304015

 Continuation of assignment from Lab 5: When all the mandatory form details (name and email) are enterd correctly to the form created in lab 5, the form is considered valid. When user clicks on submit button, show a preview of the entire form data in an alert window. (hint: refer to examples done in class)


1
Expert's answer
2022-03-02T03:04:52-0500
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
</head>
<body>
    <input type="text" class="name" placeholder="Enter name">
    <input type="text" class="email" placeholder="Enter email">
    <button onclick="dataWindow()">Sumbit</button>
    <script>
        const name = document.querySelector('.name'),
              email = document.querySelector('.email'),
              btn = document.querySelector('button');
            
        function dataWindow() {
            if (name.value && email.value) {
                alert(`Your data:\nName: ${name.value}\nEmail: ${email.value}`)
            }
        }
    </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