I have a problem with my input, where it calls my change event, only after i click away from the input. I want the event to be called when the user adds some text to my input.
function textChange(ele) {
let btn = document.getElementById("addThingBtn");
if (ele.value.length) btn.disabled = false;
else btn.disabled = true;
}
input {
height: 35px;
float: left;
text-align: center;
}
button {
width: 120px;
height: 40px;
float: left;
text-align: center;
margin-left: 5px;
}
<input type="text" id="newThingName" onchange="textChange(this);" placeholder="new thing name">
<button id="addThingBtn" onclick="addThing();" disabled> Add thing </button>
I was actually looking for the input event, not for the change event.
function textChange(ele) {
let btn = document.getElementById("addThingBtn");
if (ele.value.length) btn.disabled = false;
else btn.disabled = true;
}
input {
height: 35px;
float: left;
text-align: center;
}
button {
width: 120px;
height: 40px;
float: left;
text-align: center;
margin-left: 5px;
}
<input type="text" id="newThingName" oninput="textChange(this);" placeholder="new thing name">
<button id="addThingBtn" onclick="addThing();" disabled> Add thing </button>