I have this simple javascript function which calls other 2 functions:
<script type="text/javascript" language="javascript">
function mainfunction() {
function1()
function2()
}
function function1() {
if (//some test) {
alert('test function1');
return false;
}
}
function function2() {
if (//some test) {
alert('test function2');
return false;
}
}
</script>
i call mainfunction() like this:
<form id="form1" runat="server" onSubmit="return mainfunction()">
or like this:
<asp:Button ID="btntest" runat="server" Text="test button" OnClientClick="return mainfunction()" />
btntest is a button that just calls some class which redirects to another page.
The problem
- if i directly call any of the 2 functions
function1()orfunction2()then the button will not get executed, which is what i want. but...:
When i callmainfunction()then alert in each function works butreturn false;doesn't seem to work because the button unfortunately gets executed.
why is that? how can i call the 2 functions and let their return false; work?