﻿//Function to check form is filled in correctly before submitting
function CheckForm () {
    var notGood = 0;
	var name = document.getElementById('authorName').value;
    var nameErr = document.getElementById('authorNameError');
    var email = document.getElementById('authorEmail').value;
    var emailErr = document.getElementById('authorEmailError');
    var comment = document.getElementById('comment').value;
    var commentErr = document.getElementById('commentError');
    
    nameErr.style.display = 'none';
    emailErr.style.display = 'none';
    commentErr.style.display = 'none';
        
    if(name == ''){
        nameErr.style.display = 'block';
        notGood = 1;
    }
    if (email.length >0 && email.indexOf("@",0) == -1||email.indexOf(".",0) == -1) {
        emailErr.style.display = 'block';
        notGood = 1;
    }
    if(comment == ''){
        commentErr.style.display = 'block';
        notGood = 1;
    }
    
    if(notGood == 1){
        return false;
    }else{
	    return true;
	}
}
