[1] If there are _no_ material side-effect scripted into the functions, you can do this.
[tt]
<form name="register" action="register.cfm" method="post" onsubmit="return something(this) && othersomething(this)">
[/tt]
[2] If there are material side-side scripted into them and you don't want to miss them, you can do this.
[tt]
<form name="register" action="register.cfm" method="post" onsubmit="var x=something(this); var y=othersomething(this); return x && y;">[/tt]
[2-correction] My posting is incorrect. I would rather suggest this if the premises there are valid. (If there are alerts inside, then it would be annoying. It still not seems perfect. Maybe it is over-worked. Keep it simple then use [1])
[tt]
<form name="register" action="register.cfm" method="post" onsubmit="return something(this)&&othersomething(this) || othersomething(this)&&something(this)">
[/tt]
Lee, I still do not get the point in [2] I want to convey properly. Maybe I would go with a version not in-line like the above. It would then be free from undesirable effect as mention. Sorry!
[2-bis]
[tt]<form name="register" action="register.cfm" method="post" onsubmit="return combined(this)">
[/tt]
with the function combined(obj) defined apart.
[tt]
function combined(obj) {
var x=something(obj);
var y=othersomething(obj);
return x && y;
}
[/tt]
I agree that if the onsubmit handler is more complex than a couple of return values, it would be best handled in a separate function like you showed. I personally would use a separate function if making more than one evaluation, as your example shows. That would make things easier to read and separate the programming from the HTML code better.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.