/    Sign up×
Community /Pin to ProfileBookmark

Hi. I need to test multiple functions..

I am having problems with a possible max amount of functions you can test inside an if statement inside another function.

I’m building a validation form and i just want to test multiple functions(each function checks each field)

Like this:

function theres_probably_a_better_way_to_do_this() {

if ( (function1()==true) && (function2()==true) &&
(function3()==true) && (function4()==true) &&
(function5()==true) && (function6()==true) &&
function_well_u_get_the_point()==true) )
return true;

it turns out, the first 6 functions tested here work, but beyond that, it’s as if javascript poops out to check if it has a return

..i wouldn’t blame it, there’s gotta be a better way to do this…

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@CharlesMay 09.2006 — if (function1 == true)That's just like saying ATM machine. Try if (function1 () && function2 () && function3 () && etc())But beware, execution of the functions will stop when the first one returns false.
Copy linkTweet thisAlerts:
@deezzerauthorMay 09.2006 — It still seems to have a limit of 6 function tests for me though ...

after the 6th function, it doesn't test it, and seems to just give up testing and returns a true, when i'm explicitly making the 7th function false.

i put that 7th function in the first 6 function position, and it works..

weird..
Copy linkTweet thisAlerts:
@CharlesMay 09.2006 — That is strange. Try return function1() && function2() && function3() && etc()
Copy linkTweet thisAlerts:
@Tweak4May 09.2006 — Additionally, try stepping through your functions with a script debugger so that you can verify that each one is indeed returning what you expect it to, and so that you can monitor for errors.
Copy linkTweet thisAlerts:
@deezzerauthorMay 09.2006 — Here is the html with an action inside:

<form name="registerForm" method="post" action="register.php" onSubmit="return checkPass() && checkFirst() && checkLast() && checkEmail() && processEmail() && checkLog() && processLog()">

it's still weird...i dont think it's a problem with the script, because if i put processLog() where checkPass()'s position is, processLog will return correctly, and the 7th position won't.

So i have 2 questions..

1. does anyone know of a 6 function return limit?

2. is there a better method to do what i'm trying to do?

I was thinkin a switch statement could be better than all these individual functions..
×

Success!

Help @deezzer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...