Exforsys

Online Training

Java Script to validate email address

This is a discussion on Java Script to validate email address within the Java forums, part of the Programming Talk category; Guys I need java script to check if the users have entered valid email address or not. Kindly post them ...


Go Back   Exforsys > Programming Talk > Java

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-12-2006, 06:28 AM
Junior Member
 
Join Date: Feb 2006
Posts: 16
Raman is on a distinguished road
Java Script to validate email address

Guys

I need java script to check if the users have entered valid email address or not.

Kindly post them here

Regards
Raman
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-12-2006, 12:54 PM
Junior Member
 
Join Date: Dec 2006
Posts: 27
Quozty is on a distinguished road
Quote:
<!-- Script by hscripts.com -->
<script language=javascript>

function checkMailId(mailids)
{
var arr = new Array('.com','.net','.org','.biz','.coop','.info','.museum','.name','.pro'
,'.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag','.ai','.al',
'.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw','.az','.ba','.bb',
'.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm','.bn','.bo','.br','.bs',
'.bt','.bv','.bw','.by','.bz','.ca','.cc','.cd','.cf','.cg','.ch','.ci',
'.ck','.cl','.cm','.cn','.co','.cr','.cu','.cv','.cx','.cy','.cz','.de',
'.dj','.dk','.dm','.do','.dz','.ec','.ee','.eg','.eh','.er','.es','.et',
'.fi','.fj','.fk','.fm','.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh',
'.gi','.gl','.gm','.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy',
'.hk','.hm','.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io',
'.iq','.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li','.lk',
'.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg','.mh','.mk',
'.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt','.mu','.mv','.mw',
'.mx','.my','.mz','.na','.nc','.ne','.nf','.ng','.ni','.nl','.no','.np',
'.nr','.nu','.nz','.om','.pa','.pe','.pf','.pg','.ph','.pk','.pl','.pm',
'.pn','.pr','.ps','.pt','.pw','.py','.qa','.re','.ro','.rw','.ru','.sa',
'.sb','.sc','.sd','.se','.sg','.sh','.si','.sj','.sk','.sl','.sm','.sn',
'.so','.sr','.st','.sv','.sy','.sz','.tc','.td','.tf','.tg','.th','.tj',
'.tk','.tm','.tn','.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug',
'.uk','.um','.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu',
'.ws','.wf','.ye','.yt','.yu','.za','.zm','.zw');
var mai = mailids;
var val = true;

var dot = mai.lastIndexOf(".");
var ext = mai.substring(dot,mai.length);
var at = mai.indexOf("@");
var dom = dot - at;
var sp = mai.indexOf(" ");

if(dom >= 4 && at >1 && sp == -1)
{
for(var i=0; i<arr.length; i++)
{
if(ext == arr[i])
{
val = true;
break;
}
else
{
val = false;
}
}
if(val == false)
{
alert("Your maild "+mai+" is not corrrrect");
return false;
}
}
else
{
alert("Your maild "+mai+" is not correct");
return false;
}

return true;
}
</script> <!-- Script by hscripts.com -->
Quote:
Here we have explained with a form
a)Creating the form
<form name="test" onSubmit="return checkMailId(test.mailf.value)">
<input name=mailf type=text>
<input type=submit value=test>
</form>

b)Copy the code in to your page.

c)Things will work. The important portion is the onSubmit call in the form. "onSubmit = return checkMailId(test.mailf.value)". We call the method checkMaiId with the form fields value as the variable.

d)If the mailid check is true form action willl take place, else alert will be done.
hope that helps you, it took a quick google search to find
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-13-2006, 06:19 AM
Junior Member
 
Join Date: Feb 2006
Posts: 16
Raman is on a distinguished road
Quozty

Thanks a lot for your kind help
I learnt so much...

Thanks again
Good day to you
Raman
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

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

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


Similar Threads

Thread Thread Starter Forum Replies Last Post
FAQ: How to find people's E-mail addresses David Alex Lamb Tech FAQ 1 06-24-2007 09:57 AM
APL language FAQ Sam Sirlin Tech FAQ 0 05-12-2004 09:03 AM
FAQ: How to find people's E-mail addresses David Alex Lamb Tech FAQ 0 05-02-2004 06:30 AM
APL language FAQ Sam Sirlin Tech FAQ 0 04-18-2004 09:54 AM
[FAQ] FileMaker Pro - database for Macintosh and Windows Martin Trautmann Tech FAQ 0 04-17-2004 08:26 AM


All times are GMT -4. The time now is 07:10 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.