By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,480 Members | 1,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,480 IT Pros & Developers. It's quick & easy.

Validation in form, detecting a specific character

P: n/a
Hello,

I'm a total newbie on Javascript, and with a lot of help and some copy
and paste managed to get things running.

On my site: http://home.wanadoo.nl/homepage I use a form from
Bravenet. This works fine.

Unfortunately some persons fill in their e-mail address instead of the
URL of their page. Checking is done on empty fields but how to avoid
that a certain character "@" is used???

if (document.Bravenet.URL.value == "") {correct = false;
alert("message to display when empty")}

The above works fine for an empty field. I've been checking on
Javascript operators but can't get it working on detecting for the @
character.

Anybody a good idea??

Thanks in advance and regards from Holland.

Frank
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Frank wrote on 30 nov 2003 in comp.lang.javascript:
if (document.Bravenet.URL.value == "") {correct = false;
alert("message to display when empty")}

The above works fine for an empty field. I've been checking on
Javascript operators but can't get it working on detecting for the @
character.


Use a regular expression:

if (/@/.test(document.Bravenet.URL.value)) {
correct = false;
alert("@ detected\nmisseboel dus")
}
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2

P: n/a
"Evertjan." <ex**************@interxnl.net> wrote in message news:<Xn********************@194.109.133.29>...
Frank wrote on 30 nov 2003 in comp.lang.javascript:
if (document.Bravenet.URL.value == "") {correct = false;
alert("message to display when empty")}

The above works fine for an empty field. I've been checking on
Javascript operators but can't get it working on detecting for the @
character.


Use a regular expression:

if (/@/.test(document.Bravenet.URL.value)) {
correct = false;
alert("@ detected\nmisseboel dus")
}


Hallo Evertjan.

Tnx a lot, works fine!

Hartelijke groeten,

Frank
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.