/    Sign up×
Community /Pin to ProfileBookmark

Javascript partially working

Hi There,

Thisjavascript is partially working. It will not submit the form if there is neither a . or a @ symbol, and will submit it if there is a @ symbol, which means it isn’t checking for dots. When I enter something like kim. it prompts the user for an email address. I don’t understand why it seems to be validating in part.

var chartr = /@/i

var dot = /./i

if (document.detailsform.email.value.search(dot) == -1)
{
alert (“Please enter a valid email address.”);
return false;
}

if (document.detailsform.email.value.search(chartr) == -1)
{
alert (“Please enter a valid email address.”);
return false;
}

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@sta12sMar 24.2006 — I think you need quotes in your var declares
Copy linkTweet thisAlerts:
@Mr_JMar 24.2006 — Change

var dot = /./i


to

var dot = /./i

see if that works
×

Success!

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