{"size": 1199, "ext": "js", "max_stars_repo_path": "main.js", "max_stars_repo_name": "tungkraiwit/cpe207-web3", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "main.js", "max_issues_repo_name": "tungkraiwit/cpe207-web3", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "main.js", "max_forks_repo_name": "tungkraiwit/cpe207-web3", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 34.2571428571, "max_line_length": 204, "alphanum_fraction": 0.6580483736}

const myForm = document.querySelector('#my-form');
const nameInput = document.querySelector('#name');
const emailInput = document.querySelector('#email');
const genderInput = document.querySelector('#gender');
const subjectInput = document.querySelector('#subject');
const messageInput = document.querySelector('#message');
const msg = document.querySelector('.msg');
const userList = document.querySelector('#users');

myForm.addEventListener('submit', onSubmit);
function onSubmit(e) {
    e.preventDefault();

    //console.log(nameInput.value + ' ' + emailInput.value);

    if(nameInput.value ==='' || emailInput.value ===''){
        // alert('Please enter all fields');
        msg.classList.add('error');
        msg.innerHTML = 'Please enter all fields';
    }
    else{
        const li = document.createElement('li');
        const text = document.createTextNode(`name : ${nameInput.value}   email : ${emailInput.value}   gender : ${genderInput.value}   subject : ${subjectInput.value}   message : ${messageInput.value}`);
        li.appendChild(text);
        // console.log(li);

        userList.appendChild(li);

        nameInput.value = '';
        emailInput.value = '';
    }
}

