B
Bill
Hi.
I have a multi-page form where the user enters datails to be submitted to a
database on the final page.
To move through the pages I have Next and Previous buttons using the
following function
function nextPage(loc) {
validateForm('section'); //checks for blank fields and displays an alert
box
location.href=loc +
generateSearchStringFromStore(store); //passes escaped data string made
up from the form entries
} //to the
location in the loc parameter.
This function is called when the Next button is clicked -
<img src="images/Next-button.gif" width="90" height="32" border="0"
align="absmiddle"
onClick="nextPage('page2.html')">
Thing is, blank fields cause validateForm to display an alert box, but when
the user clciks OK page2 is displayed.
I read that if you want to stop the next page loading you have to add the
validation function to the onSubmit listener, so I tried this
<form name="section" id="section" onSubmit="validateForm('section')">
and changed the button handler to this
<img src="images/Next-Button.gif" width="90" height="32" align="absmiddle"
onClick="document.section.submit();
location.href='page2.html' +
generateSearchStringFromStore(store)">
There are no errors reported but nothing at all happens: no alert box
reporting empty fields and page2 doesn't load.
Anyone know what I'm doing wrong?
I;ve seen examples where people write something like
onSubmit="return validateForm('section')"
so I also tried returning a false value from validateForm but nothing
happened then either.
Perplexed....
I have a multi-page form where the user enters datails to be submitted to a
database on the final page.
To move through the pages I have Next and Previous buttons using the
following function
function nextPage(loc) {
validateForm('section'); //checks for blank fields and displays an alert
box
location.href=loc +
generateSearchStringFromStore(store); //passes escaped data string made
up from the form entries
} //to the
location in the loc parameter.
This function is called when the Next button is clicked -
<img src="images/Next-button.gif" width="90" height="32" border="0"
align="absmiddle"
onClick="nextPage('page2.html')">
Thing is, blank fields cause validateForm to display an alert box, but when
the user clciks OK page2 is displayed.
I read that if you want to stop the next page loading you have to add the
validation function to the onSubmit listener, so I tried this
<form name="section" id="section" onSubmit="validateForm('section')">
and changed the button handler to this
<img src="images/Next-Button.gif" width="90" height="32" align="absmiddle"
onClick="document.section.submit();
location.href='page2.html' +
generateSearchStringFromStore(store)">
There are no errors reported but nothing at all happens: no alert box
reporting empty fields and page2 doesn't load.
Anyone know what I'm doing wrong?
I;ve seen examples where people write something like
onSubmit="return validateForm('section')"
so I also tried returning a false value from validateForm but nothing
happened then either.
Perplexed....