/    Sign up×
Community /Pin to ProfileBookmark

Basic query – probably

I’m currently using a bit of JavaScript to validate a email entry in a form.

The spec has changed slightly and I now need to allow zero length strings or if they enter an address to run the check on it.

[CODE]
<SCRIPT LANGUAGE=”JavaScript”>
function checkEmail(myForm) {
if (/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/.test(myForm.emailAddr.value))
elseif (.test(myForm.emailAddr.value))
{
return (true)
}

alert(“Invalid E-mail Address! Please re-enter.”)
return (false)
}
</script>
[/CODE]

I just need to add functionality that will let it pass a zero length string.

Probably very easy if you know how, I however don’t. ?

Thanks in advance.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceApr 06.2005 — if(/^s*$/.test(myForm.emailAddr.value)
|| /^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/.test(myForm.emailAddr.value))
{
return true;
}
Copy linkTweet thisAlerts:
@AvalancheauthorApr 07.2005 — Works a treat, cheers.
×

Success!

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