/    Sign up×
Community /Pin to ProfileBookmark

two onSubmit commands

I want to use two scripts that need the [I]onSubmit[/I] command

one to validate form
onSubmit=”return validateForm(this)”

one to submit form once
onSubmit=”submitonce(this)

Here’s my form — which is working great with the script I got on this site to validate the form.
[url]http://www.iccsafe.org/download/test.html[/url]

Any suggestions?

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@PineSolPirateAug 02.2006 — Try moving the "submitonce(this)" function call to the end of the "validateForm(this)" function.

Edit:

I looked at your code, try this out...
function bothSubmit (f) {
if(validateForm(f))
{
submitonce(f);
}
else
{
return false;
}
}

I think it should be fine, I'll mess with it and update if I find any problems.
Copy linkTweet thisAlerts:
@HDCAug 02.2006 — Try this, sub in your own returns:

<form action="#" method="post" onsubmit="return (checkCheckBox(this) && checkrequired(this))">
Copy linkTweet thisAlerts:
@KorAug 02.2006 — I guess PineSolPirate's method looks better to me. It avoids calling the second function if the first one's conditions are not fulfiled.
Copy linkTweet thisAlerts:
@icc_contentauthorAug 02.2006 — Thank you! Works perfectly

here's revised form

http://www.iccsafe.org/download/test2.html
Copy linkTweet thisAlerts:
@PineSolPirateAug 02.2006 — I forgot to return true (I think thats required)
function bothSubmit (f) {
if(validateForm(f))
{
submitonce(f);
return true;
}
else
{
return false;
}
}
Copy linkTweet thisAlerts:
@CharlesAug 02.2006 — It avoids calling the second function if the first one's conditions are not fulfiled.[/QUOTE]As does HDC's. Dude, you have so got to learn Perl. It makes heavy use of such cheats that you can then apply in other languages. It's pretty standart that the right side of the "&&" operator is only evaluatetd if the left side evaluates to true.
Copy linkTweet thisAlerts:
@CharlesAug 02.2006 — I forgot to return true (I think thats required)[/QUOTE]Nope. False supresses the submission, everything else lets it go through and functions return undefined by default - in JavaScript.
Copy linkTweet thisAlerts:
@KorAug 02.2006 — You're right. Forgout about (false&&true) eval.
Copy linkTweet thisAlerts:
@PineSolPirateAug 02.2006 — Rad, now I just need to learn to trim my code down :p
Copy linkTweet thisAlerts:
@CharlesAug 02.2006 — The best way to learn good habits is to learn Pascal. The best way to learn bad habits is to learn Perl.
×

Success!

Help @icc_content 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...