Learning more about DOM - nodeValue Versus innerHTML The following is a HTML/Jav
ID: 3603780 • Letter: L
Question
Learning more about DOM - nodeValue Versus innerHTML
The following is a HTML/JavaScript question.
Create an application interface as shown below that will check for email address confirmation for signups.
1. Use the respective html and CSS files given in this assignment and build upon the structure by writing an external Javascript code to make the above interface work.
2. For each user entry of the email address, compare to check if the addresses match.
3. If the addresses match, get the value of firstChild node of the respective id element.
PLEASE use the attached INCOMPLETE JavaScript code that I have provided you to complete this assignment. The HTML and CSS codes that are attached are ONLY FOR REFERENCE. Your primary focus is on completing the JavaScript portion of the assignment. Please provide a detailed and complete answer for this question. PLEASE use JavaScript coding and programming ONLY! Do NOT answer in plain old Java/Python/programming language code, or give a few paragraphs on how to use JavaScript , or even UNIX bash or perl script. I need 100% complete/genuine help and a definitive solution to my problem.
HTML Script:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Join Email List</title>
<link rel="stylesheet" href="email_list.css">
<script src="email_list.js"></script>
</head>
<body>
<main>
<h1>Please join our email list</h1>
<form id="email_form" name="email_form" action="join.html" method="get">
<label for="email_address1">Email Address:</label>
<input type="text" id="email_address1" name="email_address1">
<span id="email_address1_error">*</span><br>
<label for="email_address2">Re-enter Email Address:</label>
<input type="text" id="email_address2" name="email_address2">
<span id="email_address2_error">*</span><br>
<label for="first_name">First Name</label>
<input type="text" id="first_name" name="first_name">
<span id="first_name_error">*</span><br>
<label> </label>
<input type="button" id="join_list" value="Join our List">
</form>
</main>
</body>
</html>
JavaScript Script:
var $ = function(id) {
return document.getElementById(id);
};
var joinList = function() {
var emailAddress1 = $("email_address1").value;
var emailAddress2 = $("email_address2").value;
var isValid = true;
if (emailAddress1 == "") {
$("emailAddress1_error") .firstChild.nodeValue = "This field is required.";
isValid = false;
} else { $("email_address1_error") .firstChild.nodeValue = ""; }
if (emailAddress2 == "") {
$("emailAddress2_error") .firstChild.nodeValue = "This field is required.";
isValid = false;
} else { $("email_address2_error") .firstChild.nodeValue = ""; }
if (("first_name") .value == "") {
$("first_name_error") .firstChild.nodeValue = "This field is required.";
isValid = false;
} else { $("first_name_error") .firstChild.nodeValue = ""; }
if (isValid) {
$("email_form") .submit();
};
window.onload = function() {
$("join_list") .onclick = joinList;
$("email_Address1") .focus();
};
CSS Script:
body {
font-family: Arial, Helvetica, sans-serif;
background-color: white;
margin: 0 auto;
width: 670px;
border: 3px solid blue;
padding: 0 2em 1em;
}
h1 {
color: blue;
margin-bottom: .5em;
}
label {
float: left;
width: 11em;
text-align: right;
}
input {
margin-left: 1em;
margin-bottom: .5em;
}
span {
color: red;
}
Explanation / Answer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Join Email List</title>
<link rel="stylesheet" href="email_list.css">
<script src="email_list.js"></script>
</head>
<body>
<main>
<h1>Please join our email list</h1>
<form id="email_form" name="email_form" action="join.html" method="get">
<label for="email_address1">Email Address:</label>
<input type="text" id="email_address1" name="email_address1">
<span id="email_address1_error">*</span><br>
<label for="email_address2">Re-enter Email Address:</label>
<input type="text" id="email_address2" name="email_address2">
<span id="email_address2_error">*</span><br>
<label for="first_name">First Name</label>
<input type="text" id="first_name" name="first_name">
<span id="first_name_error">*</span><br>
<label> </label>
<input type="button" id="join_list" value="Join our List">
</form>
</main>
</body>
</html>
JavaScript Script:
var $ = function(id) {
return document.getElementById(id);
};
var joinList = function() {
var emailAddress1 = $("email_address1").value;
var emailAddress2 = $("email_address2").value;
var isValid = true;
if (emailAddress1 == "") {
$("emailAddress1_error") .firstChild.nodeValue = "This field is required.";
isValid = false;
} else { $("email_address1_error") .firstChild.nodeValue = ""; }
if (emailAddress2 == "") {
$("emailAddress2_error") .firstChild.nodeValue = "This field is required.";
isValid = false;
} else { $("email_address2_error") .firstChild.nodeValue = ""; }
if (("first_name") .value == "") {
$("first_name_error") .firstChild.nodeValue = "This field is required.";
isValid = false;
} else { $("first_name_error") .firstChild.nodeValue = ""; }
if (isValid) {
$("email_form") .submit();
};
window.onload = function() {
$("join_list") .onclick = joinList;
$("email_Address1") .focus();
};
CSS Script:
body {
font-family: Arial, Helvetica, sans-serif;
background-color: white;
margin: 0 auto;
width: 670px;
border: 3px solid blue;
padding: 0 2em 1em;
}
h1 {
color: blue;
margin-bottom: .5em;
}
label {
float: left;
width: 11em;
text-align: right;
}
input {
margin-left: 1em;
margin-bottom: .5em;
}
span {
color: red;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.