/    Sign up×
Community /Pin to ProfileBookmark

Need help with email validation

Hi guys,

I am trying to make a form where you need JavaScript to check that you have entered a first name, and also check that a correct email address has been entered, but these 2 functions require different code. One requires onsubmit=”return validate(this) while the other requires onsubmit=”return validate_form(this) – and I am really confused as to how you can use both functions on the same form when they need 2 different onsubmits values?

Any help would be much appreciated.

Cheers

Josh

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinFeb 23.2007 — you have a submit button.

attach to that an onclick event. And be sure to set a return value so it knows whether to continue processing the form.

then attach your other validation to the forms onSubmit like you are doing now.

Alternatively you can run one function on the forms submit, and if it is fine, return the other function.

That will cause the other function to run and pass back to the form it's return value.

If you need the form reference in both functions, simply pass it from one to another.

example:
<i>
</i>function doThis(form)
{
//do something
if(ok)
{
return doSomethingElse(form);
}
else
{
return false;
}
}
×

Success!

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