Submitting & Validation of Form

S

Stu

Have a form with data sent by e-mail. Trying to
use "return onSubmit". Not working. Put alert msg in
script and never saw it. Help please. Here's info:
Validation script:
function ExitCk(FrontPage_Form1) {
box = eval("document.FrontPage_Form1.LeaveOldOpen");
boxa = eval("document.FrontPage_Form1.DeleteImmediately");
box1 = eval("document.FrontPage_Form1.ReplacementCard");
//alert(box1);
if (box1.checked == true) {
if(box.checked == false && boxa.checked == false);{
alert("\nReplacement is selected.\n Additional
input is required on next line.");
document.forms[0].elements[13].focus();
return false; }
}
else {
return tr
Form info:
<FORM METHOD='POST' onSubmit="return ExitCk(this)"
name="FrontPage_Form1" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" s-email-format="TEXT/PRE" s-
email-address="(e-mail address removed)" b-email-label-
fields="TRUE" b-email-subject-from-field="TRUE" s-email-
subject="Branch" s-date-format="%A, %d. %B %Y" s-time-
format="%I:%M:%S %p" s-builtin-fields="REMOTE_USER Date
Time" u-confirmation-url="ATM Change Confirmation.htm"
startspan --><strong>[FrontPage Save Results Component]
</strong><!--webbot bot="SaveResults" endspan i-
checksum="6561" --><P>
 
J

Jim Buyens

As you've discovered, it's very hard to mix custom form
validation with FrontPage form validation. This isn't
really a deficiency in FrontPage; it's a result of the
browser providing only one onsubmit event handler.

My current "mad scientist" approach is to:

1. Change the form's Submit button to an ordinary
pushbutton.

2. Use the pushbutton's onclick= attribute to run a
script that performs the custom validation.

3. Add a Form picture to the form (i.e. choose
From from the Insert menu, and then choose Picture.
Configure this element as a 1x1 pixel transparent GIF
and put it somewhere where the visitor is unlikely to
find it. The HTML should look like this:

<input type="image" src="images/trans.gif"
name="imgSub" border="0" width="1" height="1">

4. If your validation script finds no errors, have it
call:

document.forms[0].imgSub.click();

You gotta wonder, though, if this is enough work that you
might as well write your own JavaScript validation for
everything.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------






-----Original Message-----
Have a form with data sent by e-mail. Trying to
use "return onSubmit". Not working. Put alert msg in
script and never saw it. Help please. Here's info:
Validation script:
function ExitCk(FrontPage_Form1) {
box = eval("document.FrontPage_Form1.LeaveOldOpen");
boxa = eval("document.FrontPage_Form1.DeleteImmediately");
box1 = eval("document.FrontPage_Form1.ReplacementCard");
//alert(box1);
if (box1.checked == true) {
if(box.checked == false && boxa.checked == false);{
alert("\nReplacement is selected.\n Additional
input is required on next line.");
document.forms[0].elements[13].focus();
return false; }
}
else {
return tr
Form info:
<FORM METHOD='POST' onSubmit="return ExitCk(this)"
name="FrontPage_Form1" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" s-email-format="TEXT/PRE" s-
email-address="(e-mail address removed)" b-email-label-
fields="TRUE" b-email-subject-from-field="TRUE" s-email-
subject="Branch" s-date-format="%A, %d. %B %Y" s-time-
format="%I:%M:%S %p" s-builtin-fields="REMOTE_USER Date
Time" u-confirmation-url="ATM Change Confirmation.htm"
startspan --><strong>[FrontPage Save Results Component]
</strong><!--webbot bot="SaveResults" endspan i-
checksum="6561" --><P>

.
 
S

Stu

I agree. Thanks for the info.
-----Original Message-----
As you've discovered, it's very hard to mix custom form
validation with FrontPage form validation. This isn't
really a deficiency in FrontPage; it's a result of the
browser providing only one onsubmit event handler.

My current "mad scientist" approach is to:

1. Change the form's Submit button to an ordinary
pushbutton.

2. Use the pushbutton's onclick= attribute to run a
script that performs the custom validation.

3. Add a Form picture to the form (i.e. choose
From from the Insert menu, and then choose Picture.
Configure this element as a 1x1 pixel transparent GIF
and put it somewhere where the visitor is unlikely to
find it. The HTML should look like this:

<input type="image" src="images/trans.gif"
name="imgSub" border="0" width="1" height="1">

4. If your validation script finds no errors, have it
call:

document.forms[0].imgSub.click();

You gotta wonder, though, if this is enough work that you
might as well write your own JavaScript validation for
everything.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------






-----Original Message-----
Have a form with data sent by e-mail. Trying to
use "return onSubmit". Not working. Put alert msg in
script and never saw it. Help please. Here's info:
Validation script:
function ExitCk(FrontPage_Form1) {
box = eval("document.FrontPage_Form1.LeaveOldOpen");
boxa = eval ("document.FrontPage_Form1.DeleteImmediately");
box1 = eval("document.FrontPage_Form1.ReplacementCard");
//alert(box1);
if (box1.checked == true) {
if(box.checked == false && boxa.checked == false);{
alert("\nReplacement is selected.\n Additional
input is required on next line.");
document.forms[0].elements[13].focus();
return false; }
}
else {
return tr
Form info:
<FORM METHOD='POST' onSubmit="return ExitCk(this)"
name="FrontPage_Form1" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" s-email-format="TEXT/PRE" s-
email-address="(e-mail address removed)" b-email-label-
fields="TRUE" b-email-subject-from-field="TRUE" s-email-
subject="Branch" s-date-format="%A, %d. %B %Y" s-time-
format="%I:%M:%S %p" s-builtin-fields="REMOTE_USER Date
Time" u-confirmation-url="ATM Change Confirmation.htm"
startspan --><strong>[FrontPage Save Results Component]
</strong><!--webbot bot="SaveResults" endspan i-
checksum="6561" --><P>

.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top