/    Sign up×
Community /Pin to ProfileBookmark

multiple functions on submit

I have a form that has 2 button options when complete: submitting the form and directing to a confirm page or submitting the form/listing another account and not directing to the confirm page.

I want to have the fields validated first and then be submitted and be directed accordingly (either to the confirm page or to stay on the form and fill out another entry)

I have 2 functions: one validates that certain fields are filled out and one that checks which button is clicked. Both work separately, the validation script is called w/ onsubmit, and the button click function is called w/ an onclick function-I’m pretty sure this is the problem…

So, how do I run the validate function first, and then the button click function?

Please help- I am new to javascript so the simpler the better.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 14.2005 — Something like this:<i>
</i>function validate() {
//do stuff
if(it_validates) { button_click(); }
else {return false; }
}
×

Success!

Help @leanne 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,
)...