| | |
|
|
|
OT: JavaScript, function within function |
| message from WestSide on 19 Jul 2004 |
Hi,
I wanted to ask... first if anyone knows any active javascript forums so I
dont have to post here??
Secondly, if I have a javascript function within another function, how can I
cause the outer function to halt if the inner function has an error?
Basically I have this function inside of a function and my inner function
performs some form validation, if there is an error in the form validation, I
want the outer function to stop processing more code.........
usually after every error message I do a: return false; I put that in
there, and it seems to stop the inner function from continuing on, but not the
outer function..
Any idea?
-WS
|
| Josh Johnson replied to WestSide on 19 Jul 2004 |
One idea: Make your inner validation function return some "completed"
value, and then have your outer function check for that value. If it
doesn't return, then you can end the function.
Just to clarify, when you say inner function you mean you're calling the
function from inside another function, not defining it, right? It
should look something like...
function foo() {}
function bar() {
foo();
}
- Josh
|
| Gary White replied to Josh Johnson on 20 Jul 2004 |
function foo(){
if(test fails)
return false;
else
return true;
}
function bar() {
if (foo())
rest of code
}
Gary
|
| Gary White replied to Gary White on 20 Jul 2004 |
Good catch. It was, of course, only pseudo code. Hopefully the idea was
conveyed. ;-)
Gary
|
|
Archived message: OT: JavaScript, function within function (Macromedia Dreamweaver Web Design)