Question: I need help with this coding javascript exercise. I have attached an image of the the problem using Imgur for the questions that it is
I need help with this coding javascript exercise. I have attached an image of the the problem using Imgur for the questions that it is asking. I have also copied the HTML and Js code on the bottom as well. Please help me with this problem. I use Notepad plus.
https://imgur.com/MTqnetM
HTML CODE:
Register for an Account
Js CODE:
"use strict"; var $ = function(id) { return document.getElementById(id); };
var processEntries = function() { var header = ""; var html = ""; var required = "Required field"; var msg = "Please review your entries and complete all required fields"; var email = $("email_address").value; var phone = $("phone").value; var country = $("country").value; if ( country == "usa" ) { /* USA processing */ } else if ( country == "can" ) { /* Canada processing */ } else if ( country == "mex" ) { /* Mexico processing */ } else { alert("Please select a country."); } var contact = "Text"; if ($("email").checked) { contact = "Email"; } if ($("none").checked) { contact = "None"; } var terms = $("terms").checked;
if (email == "") { email = required; header = msg; } if (phone == "") { phone = required; header = msg; } if (country == "") { country = required; header = msg; } if (terms == false) { terms = required; header = msg; } $("registration_header").firstChild.nodeValue = header; if (header == msg) { html = html + "
var resetForm = function() { $("registration_form").reset(); $("registration_header").firstChild.nodeValue = ""; $("registration_info").innerHTML = ""; $("email_address").focus(); };
window.onload = function() { $("register").onclick = processEntries; $("reset_form").onclick = resetForm; $("email_address").focus(); };
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
