Someone ask me if we could validate an email before submiting to the server script on an 3dfa form.... So here we go

PHP Code:
errormsg=""//clear the error message if there is one
dot=email.indexOf(".",0)//find the dot

if (dot<1){//No dot?
    
errormsg+="No dot\n"
    
}
    else{
//there is a dot but must have at least two chars after it
        
ext=email.substr(dot+1)
        if (
ext.length<|| ext.length>3){
            
errormsg+="Invalid Domain\n"
            
}
    }
    
theat=email.indexOf("@",0)//find the at
if (theat<0){//no at?
 
errormsg+="No @ \n"
}
else{
//found at but is there at least one character in front of it?
    
name=email.substr(0,theat)
        if (
name.length<1){
            
errormsg+="must have name\n"
            
}
    }


trace (errormsg

Example
Source file