
// *    Description / Example:
// *    
// *    This script is written in JavaScript allowing the user to validate their html contact forms (textbox, email, textarea on this example). 
// *    
// *    This script makes sure that the person filling in information on the form isn\'t just putting info into the text boxes, so it warns the person to put the correct info, and does not submit until the script returns true.
// *    
// *    


// Checks to see if form element is empty
function isEmpty( str){
    strRE = new RegExp( );
    strRE.compile( '^[\s ]*$', 'gi' );
    return strRE.test( str.value );
}

// Checks to see if email address is 'valid'
function notValidEmail( str ){
    mailRE = new RegExp( );
    mailRE.compile( '^[\._a-z0-9-]+@[\.a-z0-9-]+[\.]{1}[a-z]{2,4}$', 'gi' );
    return !(mailRE.test( str.value ));
}

// Main validation area that holds the 'alerts' and if/else statements to loop until all info is correctly entered by the user
function checkForm( form ){

// If the email address is not 'valid' display a message
    if( notValidEmail( form.email ) ){
        alert( 'Vous devez entrer une adresse email valide' );
        return false;
    }

// Otherwise, if everything is ok...return true and let the email send.
	else{
			return true;
		}
}