//
//  Used by <asp:CustomValidator> controls on web forms
//  The ClientSideCustomEmailValidator() is a client-side javascript function that is used in conjunction with the 
//  ServerSideCustomEmailValidator VB procedure. However it is simpler - takes the email address and 
//  checks it against a list of invalid domains in an array. 
//  
//  While this function is not secure enough in itself - a competent website user would be able 
//  to easily bypass this function – it serves a purpose to quickly indicate to the user that free 
//  email addresses are not acceptable.
//

function ClientSideCustomEmailValidator(source, args)
   {
        var strInvalidEmailDomains=new Array() 
        strInvalidEmailDomains[0]='hotmail'
        strInvalidEmailDomains[1]='gmail'
        strInvalidEmailDomains[2]='yahoo'
       
        
        var i
        var strEmailAddress
        strEmailAddress = args.Value.toLowerCase()
        
        for (i=0; i < strInvalidEmailDomains.length; i++){
        
                //alert(strEmailAddress.indexOf(strInvalidEmailDomains[i]))
                
                if (strEmailAddress.indexOf(strInvalidEmailDomains[i]) == -1) {
                    args.IsValid = true
                    
                } else {
                    // if the email address has one of the above words in it
                    // it is not valid so exit loop
                    i = strInvalidEmailDomains.length + 1
                    args.IsValid = false
                }
        }

   }
