473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Multiple e-mail id checking . ?

21
if i insert multiple e-mail id in To textbox like below , how can i validate the email ids.
<abidhudavi@gmail.com>, <naseehjasi@gmail.com>, "unaise hameed" <unaise2u@gmail.com>, "Yunus Mecheri" <YunusMecheri@gmail.com>,

in google if we insert ids like above or comma separated , it will accept . anybody know the coding to validate this. in Javascript or PHP
Feb 16 '10 #1
12 2382
RamananKalirajan
608 512MB
Are you capturing this email id's in a text box?

If yes, you can do by this way.

HTML,
Expand|Select|Wrap|Line Numbers
  1.  <input type="text" id="grpEmail" name="grpEmail" />
JS,
Expand|Select|Wrap|Line Numbers
  1. var groupEmail = document.getElementById("grpEmail").value;
  2. if(groupEmail!=""&&groupEmail!=null)
  3.         {
  4.             //alert("Coming Inside");
  5.             var emailArr = groupEmail.split(",");
  6.             for(var i=0;i<emailArr.length;i++)
  7.             {
  8.                 var result = return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(emailArr[i]);
  9.                 if(result==false)
  10.                 {
  11.                     index=i;
  12.                     emailFlag=false;
  13.                     break;
  14.                 }
  15.             }
  16.             if(emailFlag==false)
  17.             {
  18.                 document.getElementById("MsgDiv").innerHTML="The Email Id "+emailArr[index]+" is Invalid. Please Change";
  19.                 return false;
  20.             }
  21.  
  22.         }
  23.  
Thanks and Regards
Ramanan Kalirajan
Feb 16 '10 #2
jyaseen
21
I try this code, with one textbox and submit button. butthere are mistakes in your code.

1) var result = return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(emailArr[i]);
in the above line it gives the Syntax error.

2) if(emailFlag==false)
the line emailFlag it says it is not declared.
so can you clear this ?
thank you for your replay
Feb 16 '10 #3
Dormilich
8,658 Expert Mod 8TB
the return does not belong there.
Feb 16 '10 #4
jyaseen
21
I removed return from code ,now it says unmatched ) in regular expression
Feb 16 '10 #5
Dormilich
8,658 Expert Mod 8TB
can’t see any unmatched )

PS. [a-zA-Z0-9_] = \w
Feb 16 '10 #6
jyaseen
21
I did not understand how the below coding works
/^[a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(emailArr[i])
this line gives the error unmatched ) in regular expression
Feb 16 '10 #7
Dormilich
8,658 Expert Mod 8TB
you didn’t copy the first (, that’s why.
Feb 16 '10 #8
jyaseen
21
Now it says emailFlag not defined ...
Feb 16 '10 #9
jyaseen
21
Now it is working, but my question is -> E-mail ids like below will accept in gmail or other email website. can I do like that.
abidhudavi@gmail.com>, <naseehjasi@gmail.com>, "unaise hameed" <unaise2u@gmail.com>, "Yunus Mecheri" <YunusMecheri@gmail.com>

your code not validating if i put an email id like this . "Yunus Mecheri" <YunusMecheri@gmail.com> . I mean it should accept this email id format.
Is it Possible ...?
Feb 16 '10 #10
Dormilich
8,658 Expert Mod 8TB
then you have to extend the RegExp …
Feb 16 '10 #11
RamananKalirajan
608 512MB
Yep it is possible, you can do it...

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <TITLE> New Document </TITLE>
  5. <META NAME="Generator" CONTENT="EditPlus">
  6. <META NAME="Author" CONTENT="">
  7. <META NAME="Keywords" CONTENT="">
  8. <META NAME="Description" CONTENT="">
  9. <script type="text/javascript">
  10.     function passValue()
  11.     {
  12.         document.getElementById('emailInp').value='<naseehjasi@gmail.com>, "unaise hameed" <unaise2u@gmail.com>, "Yunus Mecheri" <YunusMecheri@gmail.com>';
  13.         alert(document.getElementById('emailInp').value);
  14.     }
  15.  
  16.     function alertMailId()
  17.     {
  18.         var mailStr = document.getElementById('emailInp').value;
  19.         var tempStr="";
  20.  
  21.         for(var i=0;i<mailStr.length;i++)
  22.         {
  23.            if(mailStr.charAt(i).indexOf("<")>-1)
  24.            {
  25.                 for(var j=(i+1);j<mailStr.length;j++)
  26.                 {
  27.                     if(mailStr.charAt(j).indexOf(">")<=-1)
  28.                         tempStr+=mailStr.charAt(j);
  29.                     else
  30.                         {
  31.                             tempStr+=";";
  32.                             i=j;
  33.                             break;
  34.                         }
  35.                 }
  36.            }
  37.         }
  38.  
  39.         alert(tempStr);
  40.     }
  41. </script>
  42. </HEAD>
  43.  
  44. <BODY onload="passValue();">
  45. <input type="text" name="emailInp" id="emailInp" />
  46. <input type="button" value="alertMailId()"  onclick="alertMailId()"/>
  47. </BODY>
  48. </HTML>
  49.  
The value tempStr holds the mail id's alone now...

Thanks and Regards
Ramanan Kalirajan
Feb 16 '10 #12
jyaseen
21
good work , thank you I will check it and come back..
Feb 17 '10 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Rolf Wester | last post by:
Hi, I have a form with a select element with multiple="true". When using the GET method (I suppose the same happens with the POST method) I can seen that the form sends channels=CH1&channels=CH2...
66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
11
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g.,...
6
by: Ben Hallert | last post by:
Hi guys, I'm trying to figure out what bone headed mistake I made on something I put together. I've got a form (named 'context') that has a variable number of select-multiple inputs on it. ...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
9
by: Abhishek Srivastava | last post by:
Hello All, In IIS 6.0 We have a concept of worker processes and application pools. As I understand it, we can have multiple worker process per appliction pool. Each worker process is dedicated...
9
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and...
4
by: Matt Kruse | last post by:
While developing an internal IE6-only webapp, a discussion started about the 'best' way to apply classes to data tables across multiple pages. The two arguments were: 1. Apply a single class to...
35
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.