You can do this with JavaScript. Here is a sample Javascript code for
validating e-mail address.
/* ======================================================================
FUNCTION: isValidEmail
INPUT: str (string) - an e-mail address to be tested
RETURN: true, if the string contains a valid e-mail address
which is a string
plus an '@' character followed by
another string containing at least
one '.' and ending in an alpha
(non-punctuation) character.
false, otherwise
CALLS: isBlank(), isAlpha() which are defined elsewhere in
the Script Library
PLATFORMS: Netscape Navigator 3.01 and higher,
Microsoft Internet Explorer 3.02 and
higher,
Netscape Enterprise Server 3.0,
Microsoft IIS/ASP 3.0.
====================================================================== */
function isValidEmail( str ) {
// Return immediately if an invalid value was passed in
if (str+"" == "undefined" || str+"" == "null" || str+"" ==
"")
return false;
var isValid = true;
str += "";
namestr = str.substring(0, str.indexOf("@")); // everything
before the '@'
domainstr = str.substring(str.indexOf("@")+1, str.length);
// everything after the '@'
// Rules: namestr cannot be empty, or that would indicate no
characters before the '@',
// domainstr must contain a period that is not the first
character (i.e. right after
// the '@'). The last character must be an alpha.
if (isBlank(str) || (namestr.length == 0) ||
(domainstr.indexOf(".") <= 0) ||
(domainstr.indexOf("@") != -1) ||
!isAlpha(str.charAt(str.length-1)))
isValid = false;
return isValid;
} // end isValidEmail
----------------------------------------------------------------------------
----------------------------------
Cheers,
Vinod
-----Original Message-----
From: Jan D. Herzhoff [mailto:[EMAIL PROTECTED]]
Sent: 20 September 2000 18:56
To: [EMAIL PROTECTED]
Subject: check emailadress
Hi,.
I am a newbie in JSP and I would like to create a form with an error script.
If someone types an email adress without an "@" for example an error code
should appear.
How can I do this or what else do I have to check?
Thanks and best regards,
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets