EarthWeb
Developer.com
Site
windows 2000
visual c++
java
visual basic
javascripts
recommend it
 
Book
thinking in java
 
Interact
forum
guest book
jobs
jokes
what's new

share code
 
Resource
add resource
modify resource
new resource
 

[Internet Jobs]
-----
Java by E-mail:

Get the weekly e-mail highlights on Java!
-----

-

Validate an email address


Author: Real Gagnon
Author's WebSite: http://tactika.com/realhome/realhome.html

It's impossible to check if an address is REALLY valid but we can check for the presence of the "@" character.


 <HTML><HEAD>
 <SCRIPT>
 function validate_email() {
   if (document.jsform.email.value.indexOf('@',0)==-1 ||
       document.jsform.email.value.indexOf('@',0)== 0 ||
       document.jsform.email.value.indexOf('.',0)==-1) {
    alert('\nInvalid email address.')
    document.jsform.email.select()
    document.jsform.email.focus()
    return false
    }
   }
 </SCRIPT><BODY>
 Press ENTER to validate this email address
 <FORM NAME="jsform" 
       ONSUBMIT="return validate_email()">
 <INPUT NAME="email" 
        TYPE="text" 
        SIZE="50"> 
 </FORM></BODY></HTML>



Posted On: 10-Jul-1999

internet.commerce