I am trying to validate email ids in a textarea
but i am stuck at a point
as i want to validate each and every mail and also user may enters more mail
ids using comma (,) separator for every mail id I need to validate at @ and dot (.) symbols and also com see my html
and js
codes get me out of this
<html>
<head>
<style>
#email_val {
height: 100px;
width: 250px;
}
</style>
</head>
<body>
<div class="input">
<form name="myForm" onsubmit="return ValidateForm();" method="post">
<p class="label">
<h2>*Email Address:</h2>
<textarea placeholder="Enter ur mails byseparator (,) " id="email_val" name="mail"></textarea>
</p>
<p class="label">
<input type="submit">
</p>
<p class="label">
<input type="reset">
</p>
</form>
</div>
<p id="demo"></p>
<script type="text/javascript">
function ValidateForm() {
var emailList= $("#email_val").val().split(',');
for (i=0;i<emailList.length;i++)
{
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var result[i]= regex.test(emailList[i]);
if(result[i]==true)
{
document.getElementById("demo").innerHTML="Ur email address is successfully submitted";
}else
{
document.getElementById("demo").innerHTML="sorry enter a valid";
}
}
</script>
</body>
</html>