Create a User object to store the data and use the email address as the key and the user object as the value. Existing code: Register.html Registration Page Email: Phone: Address: City: State: ZIP Code: Contact Me: Text Email Do not contact me Terms and condition Register.js function validateData() { var outputTable = ""; var validInformation = true; // validate the email id var mailformat = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; if(document.getElementById('email').value.match(mailformat)) { outputTable += "EMAIL "+document.getElementById('email').value+""; } else { outputTable += "EMAIL Invalid email"; validInformation = false; } // validate phone number var regx = /^[6-9]\d{9}$/ ; if(regx.test(document.getElementById("phone").value)) { outputTable += "phonenumber "+document.getElementById('phone').value+""; } else { outputTable += "phonenumber Invalid phone "; validInformation = false; } //validate address, it cannot be empty if(document.getElementById('address').value != "") { outputTable += "address "+document.getElementById('address').value+""; } else { outputTable += "address Address cannot be empty"; validInformation = false; } //validate city, it cannot be empty if(document.getElementById('city').value != "") { outputTable += "city "+document.getElementById('city').value+""; } else { outputTable += "address city cannot be empty"; validInformation = false; } // validate zipcode: i am using the us zip code format if(/^\d{5}(-\d{4})?$/.test(document.getElementById('zip').value)) { outputTable += "zip "+document.getElementById('zip').value+""; } else { outputTable += "zip Invalid zip"; validInformation = false; } // check if the radio button is checked or not if(document.getElementById('contact').checked == true) { outputTable += "contact"+document.getElementById('contact').value+""; } else{ outputTable += "contactNot set"; validInformation = false; } // check if the check box is checked if(document.getElementById('terms').checked) { outputTable += "Terms and condtionAccepted"; } else{ outputTable += "Terms and condtionNot Accepted"; validInformation = false; } outputTable += ""; if(validInformation) { document.getElementById('results').hidden = true; alert("The users account has been registered"); } else{ // alert(); document.getElementById('results').innerHTML = outputTable; } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create a User object to store the data and use the email address as the key and the user object as the value.

Existing code:

Register.html

<html>
<head>
<title>
Registration Page
</title>
<script src="./js/register.js"></script>
</head>
<body bgcolor="Lightskyblue">
<br />
<br />
<form>
Email:
<input type="text" id="email" name="email"/> <br> <br>

Phone:
<input type="text" id="phone" name="phone"/> <br> <br>

Address:
<textarea id="address" name="address"> </textarea> <br> <br>

City:
<input type="text" id="city" name="city"/> <br> <br>

State:
<input type="text" id="state" name="state"/> <br> <br>

ZIP Code:
<input type="text" id="zip" name="zip"/> <br> <br>

Contact Me:
<input type="radio" id="contact" name="contact" value="text"/> Text
<input type="radio" id="contact" name="contact" value="email"/> Email
<input type="radio" id="contact" name="contact" value="do not contact"/> Do not contact me

<br><br>
<input type="checkbox" id="terms">Terms and condition
<br><br>
<input type="reset">
<input type="button" onclick="validateData()" value="Register">


</form>
<div id="results">

</div>
</body>
</html>

Register.js

function validateData()
{

var outputTable = "<table>";
var validInformation = true;
// validate the email id
var mailformat = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
if(document.getElementById('email').value.match(mailformat))
{
outputTable += "<tr><td>EMAIL </td><td>"+document.getElementById('email').value+"</td></tr>";

}
else
{
outputTable += "<tr><td>EMAIL </td><td>Invalid email</td></tr>";
validInformation = false;
}

// validate phone number
var regx = /^[6-9]\d{9}$/ ;
if(regx.test(document.getElementById("phone").value))
{
outputTable += "<tr><td>phonenumber </td><td>"+document.getElementById('phone').value+"</td></tr>";
}
else
{
outputTable += "<tr><td>phonenumber </td><td> Invalid phone </td></tr>";
validInformation = false;
}

//validate address, it cannot be empty
if(document.getElementById('address').value != "")
{
outputTable += "<tr><td>address </td><td>"+document.getElementById('address').value+"</td></tr>";
}
else
{
outputTable += "<tr><td>address </td><td>Address cannot be empty</td></tr>";
validInformation = false;
}

//validate city, it cannot be empty
if(document.getElementById('city').value != "")
{
outputTable += "<tr><td>city </td><td>"+document.getElementById('city').value+"</td></tr>";
}
else
{
outputTable += "<tr><td>address </td><td>city cannot be empty</td></tr>";
validInformation = false;
}

// validate zipcode: i am using the us zip code format
if(/^\d{5}(-\d{4})?$/.test(document.getElementById('zip').value))
{
outputTable += "<tr><td>zip </td><td>"+document.getElementById('zip').value+"</td></tr>";
}

else
{
outputTable += "<tr><td>zip </td><td> Invalid zip</td></tr>";
validInformation = false;
}

// check if the radio button is checked or not
if(document.getElementById('contact').checked == true)
{
outputTable += "<tr><td>contact</td><td>"+document.getElementById('contact').value+"</td></tr>";
}
else{
outputTable += "<tr><td>contact</td><td>Not set</td></tr>";
validInformation = false;

}
// check if the check box is checked
if(document.getElementById('terms').checked)
{
outputTable += "<tr><td>Terms and condtion</td><td>Accepted</td></tr>";
}
else{
outputTable += "<tr><td>Terms and condtion</td><td>Not Accepted</td></tr>";
validInformation = false;

}
outputTable += "</table>";

if(validInformation)
{
document.getElementById('results').hidden = true;
alert("The users account has been registered");

}
else{
// alert();
document.getElementById('results').innerHTML = outputTable;
}


}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education