On a website I'm doing for the paintball park I work at, I've had to do some private group booking forms through paypal, and I edited the forms to provide more information. That all is working fine; what I'm having trouble with is the scripting I'm trying to use to make sure people fill all the blanks in. On the first form I did, I messed around with it for a while and finally found, because of the paypal system, that I had to put the script in the form tag in the onsubmit function. What I did is,
<form onsubmit="
if (name0.value=='') {
alert('Please Enter a _______');
return false;
}
if (name1.value=='') {
alert('Please Enter a _______');
return false;
}
and so on, with an if statement for each of the other text inputs on the page; what I called "name" in the sample being the name of the blank according to paypal's system, and the long underscore in the alert being what the blank is asking for.
This worked fine on the first page I tried it on, and on three more pages I copied and pasted the whole page's code from and made small changes to it. Then, when I was doing a similar form on a different part of the site a few days later, I tried this same method, but it wouldn't work; the script would be bypassed and the form would submit as normal. At first I thought it might be something in the head tags that I had taken for granted on the working pages. I checked the script tags but they were identical, both the working and non-working pages' tags containing some scripting for rollover images and a popup window. The style tags naturally weren't the same, but I don't see how that could cause my problem. I couldn't find anything on the pages that either wasn't the same or I thought could cause the problem on the non-working page. With some more messing around, I found that the new page would work if I only put one if statement in the form tag, but if I added one more it would stop working again.
Here are the two pages;
working:
http://www.tfergdesign.com/basicbook.html
non-working:
http://www.tfergdesign.com/ezplregistration.html
Can anyone see any differences in the code that would cause the second form's script not to work?
note: if you look in the source code you'll see that currently the working page's script tag has a function for a popup window and the non-working page's doesn't; just in case, I tried putting the popup function on the non-working page, but it didn't make a difference.