View Full Version : Frames
sunnyview
08-30-2002, 09:09 AM
I have 2 separate forms on one document, each with their own Javascript field validation, submit buttons, etc.
Problem - when submitting the lower form, somehow validation takes place for the upper. The 2 forms seem to act as one.
Attempted solution - I created 2 separate forms and created a frameset.
Problem - I cannot create just a single scroll bar for the frameset.
2 separate scroll bars are no good.
Q: If there is a solution to either of these methods, I would love to know.
beetle
08-30-2002, 09:11 AM
How does your validation routine work? Maybe you can use mine (http://www.peterbailey.net/fValidate) :D
sunnyview
08-30-2002, 01:06 PM
Here's the script for the first:-
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkrequired(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,8)=="required") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==-1)) {
pass=false;
break;
}
}
}
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("Please make sure the "+shortFieldName+" field is properly completed.");
return false;
}
else
return true;
}
// End -->
</script>
For the second:-
<script language="JavaScript">
<!--
// Function to validate the form.
function ProcessForm()
{
var Proceed = 1;
var Message;
var FocusField;
//Method of Payment --- Method of Payment --- Method of Payment
//Method of Payment --- Method of Payment --- Method of Payment
if (!document.booking.CHolder.value)
{
Message = "Please enter CARD HOLDER'S NAME.";
FocusField = "CHolder";
Proceed = 0;
}
if (!document.booking.CExpiry.value)
{
Message = "Please enter credit card EXPIRY DATE.";
FocusField = "CExpiry";
Proceed = 0;
}
if (!document.booking.CCNO.value)
{
Message = "Please enter CREDIT CARD NO.";
FocusField = "CCNO";
Proceed = 0;
}
//Joint Renters Details --- Joint Renters Details --- Joint Renters Details
//Joint Renters Details --- Joint Renters Details --- Joint Renters Details
if (document.booking.jrenter[1].checked)
{
if (!document.booking.JExpiry.value)
{
Message = "Please enter joint renter's licence EXPIRY DATE.";
FocusField = "JExpiry";
Proceed = 0;
}
}
if (document.booking.jrenter[1].checked)
{
if (!document.booking.JState.value)
{
Message = "Please enter joint renter's ISSUING COUNTRY/STATE.";
FocusField = "JState";
Proceed = 0;
}
}
if (document.booking.jrenter[1].checked)
{
if (!document.booking.JDriverln.value)
{
Message = "Please enter joint renter's DRIVER LICENCE NO.";
FocusField = "JDriverln";
Proceed = 0;
}
}
if (document.booking.jrenter[1].checked)
{
if (!document.booking.JAddress.value)
{
Message = "Please enter joint renter's HOME ADDRESS.";
FocusField = "JAddress";
Proceed = 0;
}
}
if (document.booking.jrenter[1].checked)
{
if (!document.booking.JDOB.value)
{
Message = "Please enter joint renter's DATE OF BIRTH.";
FocusField = "JDOB";
Proceed = 0;
}
}
if (document.booking.jrenter[1].checked)
{
if (!document.booking.JFirstname.value)
{
Message = "Please enter joint renter's FIRST NAME.";
FocusField = "JFirstname";
Proceed = 0;
}
}
if (document.booking.jrenter[1].checked)
{
if (!document.booking.JSurname.value)
{
Message = "Please enter joint renter's SURNAME.";
FocusField = "JSurname";
Proceed = 0;
}
}
//Renters Details --- Renters Details --- Renters Details
//Renters Details --- Renters Details --- Renters Details
if (!document.booking.expiry.value)
{
Message = "Please enter the expiry date of your Driver's Licence.";
FocusField = "expiry";
Proceed = 0;
}
if (!document.booking.issuing.value)
{
Message = "Please enter the ISSUING COUNTRY/STATE of your Driver's Licence.";
FocusField = "issuing";
Proceed = 0;
}
if (!document.booking.driversln.value)
{
Message = "Please enter your DRIVER'S LICENCE NO.";
FocusField = "driversln";
Proceed = 0;
}
if (!document.booking.Homeaddress.value)
{
Message = "Please enter your HOME ADDRESS.";
FocusField = "Homeaddress";
Proceed = 0;
}
if (!document.booking.DOB.value)
{
Message = "Please enter your DATE OF BIRTH.";
FocusField = "DOB";
Proceed = 0;
}
if (!document.booking.Firstname.value)
{
Message = "Please enter your FIRSTNAME.";
FocusField = "Firstname";
Proceed = 0;
}
if (!document.booking.Surname.value)
{
Message = "Please enter your SURNAME.";
FocusField = "Surname";
Proceed = 0;
}
//Airport Drop-off --- Airport Drop-off - Airport Drop-off
//Airport Drop-off --- Airport Drop-off - Airport Drop-off
if (document.booking.dropoff[1].checked)
{
if (!document.booking.dropoffdate.value)
{
Message = "Please enter your scheduled NZ DROP-OFF DATE.";
FocusField = "dropoffdate";
Proceed = 0;
}
}
if (document.booking.dropoff[1].checked)
{
if (!document.booking.dropofftime.value)
{
Message = "Please enter your scheduled NZ DROP-OFF TIME.";
FocusField = "dropofftime";
Proceed = 0;
}
}
if (document.booking.dropoff[1].checked)
{
if (!document.booking.Fltno2.value)
{
Message = "Please enter your return FLIGHT NO.";
FocusField = "Fltno2";
Proceed = 0;
}
}
//Airport Drop-off --- Airport Pick-up --- Airport Pick-up
//Airport Drop-off --- Airport Pick-up --- Airport Pick-up
if (document.booking.pickup[1].checked)
{
if (!document.booking.group.value)
{
Message = "Please enter the NUMBER OF PEOPLE IN YOUR GROUP.";
FocusField = "group";
Proceed = 0;
}
}
if (document.booking.pickup[1].checked)
{
if (!document.booking.pickupdate.value)
{
Message = "Please enter your scheduled NZ PICK-UP DATE.";
FocusField = "pickupdate";
Proceed = 0;
}
}
if (document.booking.pickup[1].checked)
{
if (!document.booking.pickuptime.value)
{
Message = "Please enter your scheduled NZ PICK-UP TIME.";
FocusField = "pickuptime";
Proceed = 0;
}
}
if (document.booking.pickup[1].checked)
{
if (!document.booking.Fltno.value)
{
Message = "Please enter your FLIGHT NO.";
FocusField = "Fltno";
Proceed = 0;
}
}
//alert
if (Proceed == 1)
{
alert("The form has been successfully completed.");
return true;
}
else
{
alert( Message );
if (FocusField != "")
{
eval("document.booking." + FocusField + ".focus()");
}
return false;
}
}
//-->
</script>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.