Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Project-Gym Membership Atached Files: GYM Membership Fommipg 86836 KB) You need

ID: 3776942 • Letter: P

Question

Project-Gym Membership Atached Files: GYM Membership Fommipg 86836 KB) You need to create a form using Java Script like the one in the attached picture and validate the form using Java Script. Body should be empty, everything should be dynamically created using create Element, appendChild... functions. Before a user is allowed to submit his/her form, your form validation should do the followings 1. If all the fields are NOT filled in, then, alert box need to be popped up and not allowing him/her submit the form. 2. If the zip code contains letters or more/Mess than 5 digits, then, alert box need to be popped up and not allowing him/her submit the form. 3. If the credit card number is more/ess then 16 digits, alert box need to be popped up and not allowing him/her submit the form 4. If the email address doesn't have character, alert box need to be popped up and not allowing him/her submit the form. 5. If the phone number contains characters, instead of numbers, alert box need to be popped up and not allowing him/her submit the form. Hint: You can use the input element's attributes such as "pattern" or use java script. An input field that can contain only three letters (no numbers or special characters): Za zl(3)" title "Three letter country code

Explanation / Answer

<html>
<script>
function onload(){
   startBuildingDynamicForm();
}
function validation(){
   var x = document.forms["form"]["fname"].value;
if (x == "") {
alert("Name must be filled out");
return false;
}
   x = document.forms["form"]["lname"].value;
   if (x == "") {
alert("last Name must be filled out");
return false;
}
   x = document.forms["form"]["phone"].value;
   if (x == "") {
alert("phone must be filled out");
return false;
}
   x = document.forms["form"]["email"].value;
   if (x == "") {
alert("email must be filled out");
return false;
}
   x = document.forms["form"]["address"].value;
   if (x == "") {
alert("address must be filled out");
return false;
}
   x = document.forms["form"]["city"].value;
   if (x == "") {
alert("city must be filled out");
return false;
}
}
function startBuildingDynamicForm() {
   var states = ["telangana", "Andhra","mumbai", "chennai","banglore","kolkata","gujarat"];
var form = document.createElement("form");
var firstName = document.createElement("input");
   firstName.value="";
firstName.name="fname";
form.appendChild(firstName);
  
   var lastName = document.createElement("input");
   lastName.value="";
lastName.name="lname";
form.appendChild(lastName);
  
   var phoneNumber = document.createElement("input");
   phoneNumber.value="";
phoneNumber.name="phone";
form.appendChild(phoneNumber);
  
   var email = document.createElement("input");
   email.value="";
email.name="email";
form.appendChild(email);
  
   var address = document.createElement("input");
   address.value="";
address.name="address";
form.appendChild(address);
  
   var city = document.createElement("input");
   city.value="";
city.name="city";
form.appendChild(city);
  
   var newDiv = document.createElement('div');
var selectHTML = "";
selectHTML="<select>";
for(i = 0; i < states.length; i = i + 1) {
selectHTML += "<option value='" + states[i] + "'>" + states[i] + "</option>";
}
selectHTML += "</select>";
newDiv.innerHTML = selectHTML;
   form.appendChild(newDiv);

form.method = "POST";
form.action = "account.html";
form.onSubmit = validation();  
document.body.appendChild(form);

form.submit();
}
</script>
<body></body></html>