I am having a problem with javascript and submitting the form. The first problem that I have is that I get no errors, but the document is not saved (it did once but that was it)
The second is that I have a hidden return field to return me to a different page, but it is being ignored. After submitting, it leaves me in the same form, with the fields blank…What am I missing/doing wrong?
The form has display HTML for all fields,
The button calls a javascript function on cick
return Checkform()
Checkform() code in JS header is
function checkForm() {
//if the firstname field is blank
if (document.forms[0].ownerfirstname.value == “”) {
alert("Please enter the owner's first name.");
document.forms[0].ownerfirstname.focus();
return false;
}
//if the owners last name field is blank
if (document.forms[0].ownerlastname.value == “”) {
alert("Please enter owner's lastname.");
document.forms[0].ownerlastname.focus();
return false;
}
//if the streetaddress field is blank
if (document.forms[0].streetaddress.value == “”) {
alert("Please enter the Hinswood residence address.");
document.forms[0].streetaddress.focus();
return false;
}
//if the owners new streetaddress field is blank
if (document.forms[0].ownersaddress.value == “”) {
alert("Please enter the owners new street address.");
document.forms[0].ownersaddress.focus();
return false;
}
//if the new owners address – city is blank
if (document.forms[0].ownerscity.value == “”) {
alert("Please enter the owners new address - city.");
document.forms[0].ownerscity.focus();
return false;
}
//if the new owners state is blank
if (document.forms[0].ownerstate.value == “”) {
alert("Please enter the owners new address state.");
document.forms[0].ownerstate.focus();
return false;
}
//if the new owners state zip
if (document.forms[0].ownerszip.value == “”) {
alert("Please enter the owners new address zip code.");
document.forms[0].ownerszip.focus();
return false;
}
//if the renters start date is blank
if (document.forms[0].moveindate.value == “”) {
alert("Please enter the start date of the rental period.");
document.forms[0].moveindate.focus();
return false;
}
//if moveout date date is blank
if (document.forms[0].moveoutdate.value == “”) {
alert("Please enter the end date of the rental period.");
document.forms[0].moveoutdate.focus();
return false;
}
//if the renters firstname field is blank
if (document.forms[0].renterfirstname.value == “”) {
alert("Please enter the renter's first name.");
document.forms[0].renterfirstname.focus();
return false;
}
//if the renters lastname field is blank
if (document.forms[0].renterlastname.value == “”) {
alert("Please enter the renter's last name.");
document.forms[0].renterlastname.focus();
return false;
}
//all is well, so submit the document
document.forms[0].submit();
return true;
}
Thanks!!!
Cynthia