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)
<!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>
Comments
Leave a comment