J
John Smith
Hi,
I'm trying to do some very simple form validation and have managed to get
all of the fields checked using :
if (form.firstname.value == "") {
alert("Please include a firstname");
form.firstname.select(); }
in a fuction. This is for an order page on a site so to avoid peopl having
to fill in their address twice ( once for the delivery address and once for
the cardholder's address) I wanted to include a checkbox so that people can
tick it if they are using the same address for both details.
So far so good ! The problem I am having is I need the form validation to
skip the delivery address if the 'My address is the delivery address'
checkbox is ticked. I have tried every-way to make this work and have so far
had no luck. Anybody help shed some light on this one ? Code is below :
<script language="javascript"><!--
function simpleCheck(form) {
if (form.firstname.value == "") {
alert("Please include a firstname");
form.firstname.select(); }
if (form.lastname.value == "") {
alert("Please include a lastname");
form.lastname.select(); }
if (form.email.value == "") {
alert("Please include an email address");
form.email.select(); }
if (form.house.value == "") {
alert("Please include a house number or name");
form.house.select(); }
if (form.street.value == "") {
alert("Please include a street name");
form.street.select(); }
if (form.county.value == "") {
alert("Please include a county");
form.county.select(); }
if (form.postcode.value == "") {
alert("Please include a postcode");
form.postcode.select(); }
if (form.telephone.value == "") {
alert("Please include a telephone number");
form.telephone.select(); }
<!-- delivery alerts -->
function notChecked( box ){
if( form.deliveryadd ){
return true;
}
else{
if (form.firstname2.value == "") {
alert("Please include a delivery firstname");
form.firstname2.select(); }
if (form.lastname2.value == "") {
alert("Please include a delivery lastname");
form.lastname2.select(); }
if (form.email2.value == "") {
alert("Please include a delivery email address");
form.email2.select(); }
if (form.house2.value == "") {
alert("Please include a delivery house number or name");
form.house2.select(); }
if (form.street2.value == "") {
alert("Please include a delivery street name");
form.street2.select(); }
if (form.county2.value == "") {
alert("Please include a delivery county");
form.county2.select(); }
if (form.postcode2.value == "") {
alert("Please include a delivery postcode");
form.postcode2.select(); }
if (form.telephone2.value == "") {
alert("Please include a delivery telephone number");
form.telephone2.select(); }
if (form.delivery_date.value == "") {
alert("Please include a delivery date");
form.delivery_date.select(); }
}
form.method="post";
form.target="_self";
form.action="myform.asp";
form.submit();
}
}
I'm trying to do some very simple form validation and have managed to get
all of the fields checked using :
if (form.firstname.value == "") {
alert("Please include a firstname");
form.firstname.select(); }
in a fuction. This is for an order page on a site so to avoid peopl having
to fill in their address twice ( once for the delivery address and once for
the cardholder's address) I wanted to include a checkbox so that people can
tick it if they are using the same address for both details.
So far so good ! The problem I am having is I need the form validation to
skip the delivery address if the 'My address is the delivery address'
checkbox is ticked. I have tried every-way to make this work and have so far
had no luck. Anybody help shed some light on this one ? Code is below :
<script language="javascript"><!--
function simpleCheck(form) {
if (form.firstname.value == "") {
alert("Please include a firstname");
form.firstname.select(); }
if (form.lastname.value == "") {
alert("Please include a lastname");
form.lastname.select(); }
if (form.email.value == "") {
alert("Please include an email address");
form.email.select(); }
if (form.house.value == "") {
alert("Please include a house number or name");
form.house.select(); }
if (form.street.value == "") {
alert("Please include a street name");
form.street.select(); }
if (form.county.value == "") {
alert("Please include a county");
form.county.select(); }
if (form.postcode.value == "") {
alert("Please include a postcode");
form.postcode.select(); }
if (form.telephone.value == "") {
alert("Please include a telephone number");
form.telephone.select(); }
<!-- delivery alerts -->
function notChecked( box ){
if( form.deliveryadd ){
return true;
}
else{
if (form.firstname2.value == "") {
alert("Please include a delivery firstname");
form.firstname2.select(); }
if (form.lastname2.value == "") {
alert("Please include a delivery lastname");
form.lastname2.select(); }
if (form.email2.value == "") {
alert("Please include a delivery email address");
form.email2.select(); }
if (form.house2.value == "") {
alert("Please include a delivery house number or name");
form.house2.select(); }
if (form.street2.value == "") {
alert("Please include a delivery street name");
form.street2.select(); }
if (form.county2.value == "") {
alert("Please include a delivery county");
form.county2.select(); }
if (form.postcode2.value == "") {
alert("Please include a delivery postcode");
form.postcode2.select(); }
if (form.telephone2.value == "") {
alert("Please include a delivery telephone number");
form.telephone2.select(); }
if (form.delivery_date.value == "") {
alert("Please include a delivery date");
form.delivery_date.select(); }
}
form.method="post";
form.target="_self";
form.action="myform.asp";
form.submit();
}
}