Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

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????
0
gianitoo
Asked:
gianitoo
1 Solution
 
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now