[Javascript] Email validation question

Josiah Gordon jgordon at directfile.com
Fri Jun 8 12:35:49 CDT 2001


Try a regular expression search for multiple occurrences of "@".

var pattern = new RegExp("/@{2,}/"); 
var fieldValue = "john at aol.com, kim at aol.com";
var result = fieldValue.match(pattern);
if (result != null) {
	//multiple @s found
}


--Josiah Gordon

-----Original Message-----
From: javascript-admin at LaTech.edu [mailto:javascript-admin at LaTech.edu]On
Behalf Of Neal, Craig
Sent: Thursday, June 07, 2001 10:21 AM
To: 'javascript at LaTech.edu'
Subject: [Javascript] Email validation question


I'm having trouble finding the answer I need in my JavaScript books
regarding client-side JavaScript validation.

Typical email validation routines include:

if (document.form.formfield.value.indexOf("@") == -1)

However I need to make sure that a user doesn't enter 2 or more email
addresses in the form field and this only tests to see if there are no @
characters. How do I code it to test for 0 and 2 or more?

Thanks

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
http://www.LaTech.edu/mailman/listinfo/javascript






More information about the Javascript mailing list