Link to home
Start Free TrialLog in
Avatar of gianitoo
gianitoo

asked on

2 onsubmit events

is it possible to have 2 onsubmit events?

<form name="form1" method="post" action="http://www.pikefest.org/form/afp.asp?formid=36"OnSubmit="validateemail;return xlaAFPvalidate(this)">
my second does not work ok if i have 2 events????
Avatar of Roonaan
Roonaan
Flag of Netherlands image

I think you should have:

onsubmit="if(!validateEmail()) {return false;} return xlaAFPvalidate(this);"

-r-
Avatar of smaccari
smaccari

You can chain two function calls in, your handler without problm if that is what you look for.

<form name="form1" method="post" action="http://www.pikefest.org/form/afp.asp?formid=36" OnSubmit="validateemail();return xlaAFPvalidate(this)">
ASKER CERTIFIED SOLUTION
Avatar of mvan01
mvan01
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
bbbbbbb ... Roonan was right.

If the logic in each function is correct, then you want both successful for "post" to proceed.  His logic will only run xlaAFPvalidate() if validateemail() was successful (i.e.: returned true).

* Roonan,

would this also work?

onSubmit="return !validateemail(); return xlaAFPvalidate(this);"

??

Peace and joy.  mvan
@mvan01

In your setup the xlaFPValidate(this) will never be executed, unless you add an if() clause surrounding the validateemail() call.

-r-
You can try to use:

onsubmit="return validateemail() && xlaAFPvalidate(this);"

-r-
@Roonan,

I do not doubt what you say.  I wonder why, though.  If validateemail() returns true, then !validateemail() evaluates false.  So return !validateemail() should return false when validateemail() is true.  And the converse, of course.

Peace and joy.  mvan
mvan

You have to consider that whenever you have a return the onsubmit is exited whether or not you return true or false.

So when considering a statement: return validateemail(); return xlaFPvalidate(this);
The second validation will never be called because the result of validateemail() is always returned no matter what its value is.

-r-
<NO POINTS>

When you want to execute "xlaAFPvalidate" only when "validateemail"  return true;
You could do following..define a inline function,




<form name="form1" method="post" action="http://www.pikefest.org/form/afp.asp?formid=36" onSubmit="function () { if (validateemail()) { return xlaAFPvalidate(this); } return false; } ">

Thanks, but ... why did you accept my answer?  I think it did not work, and said so right below it.  Then Roonaan explained some details I had not considered.

With all due respect, I think Roonaan deserved the 'A'.

Peace and joy.  mvan