Question: Can someone please help me fix the code? Email Validation is not working. Please Bold the code that you modified to it will be easier
Can someone please help me fix the code? Email Validation is not working. Please Bold the code that you modified to it will be easier for me to go back to my code and make the changes.
About Us
Direction
Application Form
function doClear()
{
document.Application.fname.value = "";
document.Application.lname.value = "";
document.Application.address.value = "";
document.Application.city.value = "";
document.Application.state.value = "";
document.Application.zip.value = "";
document.Application.phone.value = "";
document.Application.email.value = "";
document.Application.gender[0].checked = false;
document.Application.gender[1].checked = false;
document.Application.membershipPeriod[0].checked = false;
document.Application.membershipPeriod[1].checked = false;
document.Application.membershipPeriod[2].checked = false;
document.Application.membershipPeriod[3].checked = false;
document.Application.name.value = "";
document.Application.pass.value = "";
document.Application.confirmpass.value = "";
return;
}
function doSubmit()
{
if (validateText() == false)
{
return;
}
if (validation() == false)
{
return;
}
if (validateForm() == false)
{
alert("What is your Gender: Male or Female?");
return;
}
if (validateRadio() == false)
{
alert("Choose a membership type.");
return;
}
if (validateCard() == false)
{
return;
}
if (validateAccount() == false)
{
alert("Please create an account to complete your application.");
return;
}
alert("Thank You for becoming a member of Sarkar's Elite Fitness. You will get your membership card within 4-5 business days. You also need to check your email to verify the email address associated with your account. If you have any questions, comments or concerns, please feel free to contact us.");
return;
}
function validateText()
{
var customer = document.Application.fname.value;
if (customer.length == 0)
{
alert("What is your first name?");
return false;
}
var customer = document.Application.lname.value;
if (customer.length == 0)
{
alert("What is your last name?");
return false;
}
var address = document.Application.address.value;
if (address.length == 0)
{
alert("What is your address?");
return false;
}
var city = document.Application.city.value;
if (city.length == 0)
{
alert("Enter your city.");
return false;
}
var state = document.Application.state.selectedIndex;
if (state == 0)
{
alert("What is your State?");
return false;
}
var zip = document.Application.zip.value;
if (zip.length == 0)
{
alert("What is your Zip code?");
return false;
}
else if (zip.length 5)
{
alert("Zipcode must be 5 digits code");
return false;
}
if (!validation())
return false;
var email = document.Application.email.value;
if (email.value == "")
{
window.alert("Please enter a valid email address.");
email.focus();
return false;
}
if(email.value.indexOf("@",0)
{
window.alert("Please enter a valid email address.");
email.focus();
return false;
}
if(email.value.indexOf(".",0)
{
window.alert("Please enter a valid email address.");
email.focus();
return false;
}
}
function validateForm()
{
if ((document.getElementById("m").checked == false) && (document.getElementById("f").checked == false))
{
return false;
}
return true;
}
function validation()
{
var phone = document.getElementsByName('phone');
if (phone[0].value == "")
{
alert("What is your phone number?");
phone[0].focus();
return false;
}
else if (phone[0].value.length 10)
{
alert("Phone Number must be 10 digits number");
phone[0].focus();
return false;
}
return true;
}
function validateRadio()
{
var getMembershipPeriod = document.getElementsByName("membershipPeriod");
for (var i = 0; i
{
if (getMembershipPeriod[i].checked)
{
return true;
}
}
return false;
}
function validateCard()
{
var cardNumber = document.getElementById("cardNumber").value;
var cvv = document.getElementById("cvv").value;
var date1 = document.getElementById("date1").value;
var date2 = document.getElementById("date2").value;
if (cardNumber == '')
{
alert("Enter a valid credit/debit card number.");
return false;
}
else if (cardNumber.length 16)
{
alert("Credit/debit card number must be 16 digits card number.");
return false;
}
if (cvv == '')
{
alert("Enter the CVV Security code which is located at the back of your card.");
return false;
}
else if (cvv.length 3)
{
alert("CVV Security code must be 3 digits");
return false;
}
else if (date1 == '')
{
alert("Select the Expiration Month.");
return false;
}
else if (date2 == '')
{
alert("Select the Expiration Year.");
return false;
}
else
{
return true;
}
}
function validateAccount()
{
var username = document.getElementById("username").value;
var password = document.getElementById("pass").value;
var cPassword = document.getElementById("confirmpass").value;
if (username == '')
{
alert("Choose a Username that is between 6 to 8 characters.");
return false;
}
else if (username.length
{
alert("Username can't be less than 6 characters.");
return false;
}
if (password == '')
{
alert("Choose a Password that is between 6 to 8 characters.");
return false;
}
else if (password.length
{
alert("Password can't be less than 6 characters.");
return false;
}
if (cPassword == '')
{
alert("Please re-enter your password");
return false;
}
else if (cPassword.length
{
alert("Password can't be less than 6.");
return false;
}
else if (password != cPassword)
{
alert("Passwords didn't match.");
return false;
}
return true;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
