const nome = document.getElementById("nome");
const nota = document.getElementById("nota");

const btn = document.getElementById("btn-submit");
console.log("Cheguei!");

let numberRegExp = new RegExp('^[0-9-() ]+$');
let letterRegExp = new RegExp('^[a-zA-Z ]+$');
let biRegExp = new RegExp('^[a-zA-Z0-9]+$');
let emailRegExp = new RegExp('^[A-Za-z0-9._-]{3,}@[A-Za-z]{3,}[.]{1}[A-Za-z.]{2,6}$');
//document.querySelector("#idClasse").classList.add("is-invalidoooooo");

console.log('Pegar os smalls: ', document.querySelector('.form-group small'));

function nomeWarning(small){
	nome.className = "form-control is-warning";
	small.style.visibility = "visible";
	small.style.color = "#ffc107";
	small.innerText = "Campo Nome Completo é obrigatório!";
	btn.setAttribute('disabled', 'disabled');
}

function nomeValid(small){
	nome.className = "form-control is-valid";
	btn.removeAttribute('disabled');
	small.style.visibility = "hidden";
}

nome.addEventListener("keyup", function(){
	let small = nome.parentElement.querySelectorAll("small")[1];
	if(nome.value === ''){
		nomeWarning(small);
	} else {
		nomeValid(small);
	}
});

function notaWarning(small){
	nota.className = "form-control";
	small.style.visibility = "hidden";
	btn.removeAttribute('disabled');
}

function notaValid(small){
	nota.className = "form-control is-valid";
	btn.removeAttribute('disabled');
	small.style.visibility = "hidden";
}

nota.addEventListener("keyup", function(){
	let small = nota.parentElement.querySelectorAll("small")[1];
	if(nota.value === ''){
		notaWarning(small);
	} else {
		notaValid(small);
	}
});


btn.addEventListener("click", function(){
	let smallNome = nome.parentElement.querySelectorAll("small")[1];
	let smallNota = nota.parentElement.querySelectorAll("small")[1];
	if(nome.value == ''){
        nomeWarning(smallNome);
    } else {
		nomeValid(smallNome);
	}
	if(nota.value == ''){
        notaWarning(smallNota);
    } else {
		notaValid(smallNota);
	}
});