/    Sign up×
Community /Pin to ProfileBookmark

Multiple onSubmit option in Forms

I want to include multiple Javascript validation code in my form. for example, the next code uses one validation script like this:

<form name=”form” method=”post” action=”/cgi-bin/registerform.pl” onSubmit=”return checkFields();”>

Now, how can I add another onSubmit Javascript validation code to the line above without removing the first onSubmit argument, so the Form could check multiple onSubmit scripts inside the form?

Thanks in advance for help.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@brendandonhueSep 02.2003 — Create one onSubmit function that calls all of the individual functions that need to be run.
Copy linkTweet thisAlerts:
@mayassinauthorSep 02.2003 — Thanks, but I've tried it and did not work. Could you show me how to do it exactly?

Thnx.
Copy linkTweet thisAlerts:
@brendandonhueSep 02.2003 — Something like this

<script type="text/javascript">

function OnSubmit1()

{First onSubmit goes here}

function OnSubmit2

{Second onSubmit goes here}

function OnSubmit3()

{Third onSubmit goes here}

function checkFields()

{

OnSubmit1();

OnSubmit2();

OnSubmit3();

}

</script>
×

Success!

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