function test(mail)
{
    var a = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
    return a.test(mail);
}

function checkup()
{
    var mailBox = document.getElementById("mailInfo");
    var nameBox = document.getElementById("name");
    var commentBox = document.getElementById("comment");
    var codeBox = document.getElementById("code");
    var caseCocher = document.getElementById("hideMail");
    
    if(nameBox.value == "")
    {
        alert("Field 'name' must be not empty");
        return false;
    }
    if(caseCocher.checked==true)
    {
        if(mailBox.value == "")
        {
            alert("You check to hide email. Enter a valid address.");
            return false;
        }
    }
    
    
    if(mailBox.value != "")
    {
        if(!test(mailBox.value))
        {
            alert("Enter a valid address please.");
            return false;
        }
    }
    
    if(commentBox.value == "")
    {
        alert("Field 'comment' must be not empty");
        return false;
    }
    
    if(codeBox.value == "")
    {
        alert("Field 'code' must be not empty");
        return false;
    }
    return true;

}
