473,396 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Validation in form, detecting a specific character

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
2 2217
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: AnnMarie | last post by:
<script language="JavaScript" type="text/javascript"> <!-- function validate(theForm) { var validity = true; // assume valid if(frmComments.name.value=='' && validity == true) { alert('Your...
72
by: Stephen Poley | last post by:
I have quite often (as have probably many of you) come across HTML forms with irritating bits of Javascript attached. The last straw on this particular camel's back was a large form I was asked to...
4
by: Ray | last post by:
I've got a couple of webpages that I am trying to validate but I get this error message when trying to validate them with the www.w3.org HTML validator: I was not able to extract a character...
5
by: EviL KerneL | last post by:
Hi - I am trying to figure out a way to enforce the validation included for this form based on whether the user chooses "email" or "phone" as the contact choice. Right now it is set to enforce...
5
by: Richard Brown | last post by:
Ok, I've been looking through the .NET SDK docs and stuff. I'm wondering if you can provide a control extender that does generic validation or functionality just by dropping it on the form. For...
9
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be...
2
by: this one | last post by:
I have the following code <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript"...
1
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I have a KeyDown event in which I would like to determine if the current key is a standard character (i.e., from the ASCII character set). In C I would use something like the isascii...
2
by: Sudhakar | last post by:
A) validating username in php as part of a registration form a user fills there desired username and this is stored in a mysql. there are certain conditions for the username. a) the username...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.