Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Design Forum > HTML / CSS
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-22-2007, 02:12 AM   #1 (permalink)
jamesbond
Junior Member
 
Join Date: May 2007
Location: India
Posts: 2
Default Email Validation but small doubt

hi friends..........

The email validation script is working well but inbetween without comma it accepts but i want without comma it wont accept the email address that mean (2 emal or 3,4....) can u please check the script as i given below...........


Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script language="javascript"> function validateEmail(addr,man,db) { if (addr == '' && man) { if (db) alert('email address is mandatory'); return false; } if (addr == '') return true; var invalidChars = '\/\'\\ ";:?!()[]\{\}^|'; for (i=0; i<invalidChars.length; i++) { if (addr.indexOf(invalidChars.charAt(i),0) > -1) { if (db) alert('email address contains invalid characters'); return false; } } for (i=0; i<addr.length; i++) { if (addr.charCodeAt(i)>127) { if (db) alert("email address contains non ascii characters."); return false; } } var atPos = addr.indexOf('@',0); if (atPos == -1) { if (db) alert('email address must contain an @'); return false; } if (atPos == 0) { if (db) alert('email address must not start with @'); return false; } if (addr.indexOf('@', atPos + 1) > - 1) { if (db) alert('email address must contain only one @'); return false; } if (addr.indexOf('.', atPos) == -1) { if (db) alert('email address must contain a period in the domain name'); return false; } if (addr.indexOf('@.',0) != -1) { if (db) alert('period must not immediately follow @ in email address'); return false; } if (addr.indexOf('.@',0) != -1){ if (db) alert('period must not immediately precede @ in email address'); return false; } if (addr.indexOf('..',0) != -1) { if (db) alert('two periods must not be adjacent in email address'); return false; } var suffix = addr.substring(addr.lastIndexOf('.')+1); if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') { if (db) alert('invalid primary domain in email address'); return false; } return true; } </script> </head> <body> <form name="myform" > <input name="email" value="" size="25" maxlength="40" type="text"><br><input name="submitit" value="Validate Email" onClick="if (validateEmail(form.email.value,1,1)) {alert('email address accepted'); return false;}" type="submit"> </form> </body> </html>

can u please check it as soon as possible

thanks in advance
jamesbond
jamesbond is offline   Reply With Quote
Sponsored Links
Old 06-05-2007, 09:02 AM   #2 (permalink)
ophir.oren
Junior Member
 
Join Date: Dec 2006
Location: Israel
Posts: 6
Default Re: Email Validation but small doubt

why not use regular expressions?
__________________
מחפשים לבנות אתר אינטרנט? אנו מציעים שירות בניית אתרים. המערכות שלנו מכילות מערכות לניהול אתרים מתקדמות ונוחות לתפעול.

Seeking for good graphic design? DCagan - Graphic design, catalog design & print catalog in New York
ophir.oren is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 09:23 AM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums