affiliate marketing Dot Net Posts: Multiple email validation seperated by comma using javascript

Saturday, 2 July 2011

Multiple email validation seperated by comma using javascript


function echeck(str) 


var at="@"; 
var dot="."; 
var lat=str.indexOf(at); 
var lstr=str.length; 
var ldot=str.indexOf(dot); 
if (str.indexOf(at)==-1) 

alert("Invalid E-mail ID"); 
return false; 


if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) 

alert("Invalid E-mail ID:"+str+""); 
return false; 


if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) 

alert("Invalid E-mail ID:"+str+""); 
return false; 


if (str.indexOf(at,(lat+1))!=-1) 

alert("Invalid E-mail ID:"+str+""); 
return false; 


if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) 

alert("Invalid E-mail ID:"+str+""); 
return false; 


if (str.indexOf(dot,(lat+2))==-1) 

alert("Invalid E-mail ID:"+str+""); 
return false; 


if (str.indexOf(" ")!=-1) 

alert("Invalid E-mail ID"); 
return false; 


return true; 


function LTrim( value ) 


var re = /\s*((\S+\s*)*)/; 
return value.replace(re, "$1"); 



// Removes ending whitespaces 
function RTrim( value ) 


var re = /((\s*\S+)*)\s*/; 
return value.replace(re, "$1"); 



// Removes leading and ending whitespaces 
function trim( value ) 


return LTrim(RTrim(value)); 


Here : take 
function checkMailIds(id,id2) 


debugger; 
var cnt=0; 
var mailids=id.value; 
var str=mailids.split(","); 

for(var i=0;i{
var obk=str[i];
var obk=trim(obk);
//alert(obk);
if(echeck(obk)==false)
{

id2.disabled=true;
return false;

}
else
{

cnt=parseInt(cnt)+1;
if(cnt==str.length)
{

id2.disabled=false;
return true;
}

//return true;
}



}

}

function chktxt()
{

var txtemail=document.getElementById('txtemail');
if(txtemail.value=="")
{
alert("Enter Emailid");
return false;
}
else
{
return true;
}

No comments:

Post a Comment