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????
LVL 1
gianitooAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RoonaanCommented:
I think you should have:

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

-r-
0
smaccariCommented:
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)">
0
mvan01Commented:
Maybe be sure this line:

return false;

is in your first called function.  By default, it would return true; and this tells the "post" or "submit" action that the event is successful (and thus over, not getting to execute the second function).  If  'return false;' is NOT in your first function, then you must specify it in the onSubmit line:

... onSubmit="validateemail(); return false; xlaAFPvalidate(this);" ...

I've seen it done both ways.

Peace and joy.  mvan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

mvan01Commented:
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
0
RoonaanCommented:
@mvan01

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

-r-
0
RoonaanCommented:
You can try to use:

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

-r-
0
mvan01Commented:
@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
0
RoonaanCommented:
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-
0
Pravin AsarPrincipal Systems EngineerCommented:
<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; } ">

0
mvan01Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.