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
12 2382
Are you capturing this email id's in a text box?
If yes, you can do by this way.
HTML, - <input type="text" id="grpEmail" name="grpEmail" />
JS, - var groupEmail = document.getElementById("grpEmail").value;
-
if(groupEmail!=""&&groupEmail!=null)
-
{
-
//alert("Coming Inside");
-
var emailArr = groupEmail.split(",");
-
for(var i=0;i<emailArr.length;i++)
-
{
-
var result = return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(emailArr[i]);
-
if(result==false)
-
{
-
index=i;
-
emailFlag=false;
-
break;
-
}
-
}
-
if(emailFlag==false)
-
{
-
document.getElementById("MsgDiv").innerHTML="The Email Id "+emailArr[index]+" is Invalid. Please Change";
-
return false;
-
}
-
-
}
-
Thanks and Regards
Ramanan Kalirajan
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
the return does not belong there.
I removed return from code ,now it says unmatched ) in regular expression
can’t see any unmatched )
PS. [a-zA-Z0-9_] = \w
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
you didn’t copy the first (, that’s why.
Now it says emailFlag not defined ...
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 ...?
then you have to extend the RegExp …
Yep it is possible, you can do it... - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
<HTML>
-
<HEAD>
-
<TITLE> New Document </TITLE>
-
<META NAME="Generator" CONTENT="EditPlus">
-
<META NAME="Author" CONTENT="">
-
<META NAME="Keywords" CONTENT="">
-
<META NAME="Description" CONTENT="">
-
<script type="text/javascript">
-
function passValue()
-
{
-
document.getElementById('emailInp').value='<naseehjasi@gmail.com>, "unaise hameed" <unaise2u@gmail.com>, "Yunus Mecheri" <YunusMecheri@gmail.com>';
-
alert(document.getElementById('emailInp').value);
-
}
-
-
function alertMailId()
-
{
-
var mailStr = document.getElementById('emailInp').value;
-
var tempStr="";
-
-
for(var i=0;i<mailStr.length;i++)
-
{
-
if(mailStr.charAt(i).indexOf("<")>-1)
-
{
-
for(var j=(i+1);j<mailStr.length;j++)
-
{
-
if(mailStr.charAt(j).indexOf(">")<=-1)
-
tempStr+=mailStr.charAt(j);
-
else
-
{
-
tempStr+=";";
-
i=j;
-
break;
-
}
-
}
-
}
-
}
-
-
alert(tempStr);
-
}
-
</script>
-
</HEAD>
-
-
<BODY onload="passValue();">
-
<input type="text" name="emailInp" id="emailInp" />
-
<input type="button" value="alertMailId()" onclick="alertMailId()"/>
-
</BODY>
-
</HTML>
-
The value tempStr holds the mail id's alone now...
Thanks and Regards
Ramanan Kalirajan
good work , thank you I will check it and come back..
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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()
|
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.,...
|
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. ...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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,...
| |