
function form_check(){
    var text = 'De volgende velden zijn niet/onjuist ingevuld:\n';
    var check = true;
    
    if( document.form_contact.contact_name_first.value == '' ){
        text += '- Voornaam\n';    
        check = false;
    }
    if( document.form_contact.contact_name_last.value == '' ){
        text += '- Achternaam\n';    
        check = false;
    }
    if( document.form_contact.contact_message.value == '' ){
        text += '- Bericht\n';    
        check = false;
    }
    
    
    if( check_email( document.form_contact.contact_email.value ) == false ){
        text += '- Emailadres\n';
        check = false;
    }

    
    if( check == false ){
        alert( text );
        return false;
    }else{
        return true;
    }
}


function check_email( email ) {
    
    valid_chars = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

    var email_check = true;
    var found_at    = false;
    var found_dot   = false;

    if( email.length < 6 ){
        return false;
    }else{
        for(i=0; i < email.length ;i++){
            if( email.charAt(i) == '@' ){
                found_at = true;
                break;
            }
        }
        
        for(i=0; i < email.length ;i++){
            if( email.charAt(i) == '.' ){
                found_dot = true;
                break;
            }
        }
        
        if( (found_at == false) || (found_dot == false) ){
            return false;
        }
        
    
        for(i=0; i < email.length ;i++){
            if(valid_chars.indexOf(email.charAt(i))<0){ 
                return (false);
            }       
        }
    }
    
        
    return true;
} 
