I have some inputs and a next button. At the moment I validated that the button is deactivated. If I fill in the name field, the button is activated.
var b = document.getElementById('button');
var input = document.getElementById("inputtext");
input.addEventListener("input", displayButton);
function displayButton() {
if (input.value === "") {
b.disabled = true;
} else {
b.disabled = false;
}
}
displayButton();
<input type="text" id="inputtext" placeholder="Enter name">
<input type="text" id="inputtext2" placeholder="Enter last_name">
<input type="text" id="inputtext3" placeholder="Enter country">
<button id="button">Next</button>
If I only want to verify that the first and last name are filled and not the city field, how would it be? And also if I click on the disabled button insert a text that says "First fill all the fields".