String.prototype.trim = function() {
    a = this.replace(/^\s+/, '');
    return a.replace(/\s+$/, '');
};




function isFormCompleted(){
    
    var inputsIds = isFormCompleted.arguments;
    var input = null;
    
    for(var i = 0; i < inputsIds.length; i ++){
        input = document.getElementById(inputsIds[i]);
        if( input.type == "text" && (input.value.trim() == "" || input.value == null) ){
            alert("Please, complete all required field(s) first.");
            
            return false;
        }
    }
    
    return true;
}


//function to check valid email address
function isValidEmail(emailInputId){

    var validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
    var strEmail = document.getElementById(emailInputId).value;
    
    // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) {
        alert('A valid e-mail address is required.\nPlease amend and retry');
        
        return false;
    } 
    
    return true; 
}


