function echeck(field) {
var str = field.value;
var at = "@";
var dot=".";
var nos="0123456789";
var lat=str.indexOf(at);
var lstr=str.length;
var ldot=str.indexOf(dot);
var com=str.substring(str.lastIndexOf(dot)+1);
if (str.indexOf(at)==-1){
return false;
}
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
return false;
}
if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
return false;
}
if (str.indexOf(at,(lat+1))!=-1){
return false;
}
if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot ){
return false;
}
for(var i=0;i<com.length;i++){
if ((com.charAt(i)<='0' && com.charAt(i)<='9')){
alert("Invalid e-Mail ID anuj >>"+com);
return false;
}
}
if (str.indexOf(dot,(lat+2))==-1){
return false;
}
if (str.indexOf(" ")!=-1){
return false;
}
var elen=str.substring(str.indexOf(dot)+1);
if (elen.length<2){
return false;
}
return true;
}
If you're going to "validate" an e-mail address, make sure you do it right. I've seen at least one blog post where the writer stopped doing business with a company because their website rejected his e-mail address (which had a dash in it, if I remember right).
In the web application I work on, we don't validate e-mail addresses. It's up to the user to put in their e-mail address correctly. You might want to reconsider whether you even need to validate e-mail addresses. What benefits does that validation provide?
There will be plenty of time to discuss your objections when and if you return. The cargo is this tiny ad: