Yes try this way
first use the keyup event to instantly track changes in the input, then check if both values matter and show / hide the right button:
$('input').on('keyup',function(){
var complete = true;
$allInputs.each(function(){
if($(this).val() === "") complete = false;
});
if(complete){
$button.hide();
$button2.show();
} else {
$button.show();
$button2.hide();
}
});
see an example here: https://jsfiddle.net/qeubzwvy/6/
or in pure javascript if you prefer:
var allInputs = document.getElementsByTagName("input"),
button1 = document.getElementById('input-blue-img'),
button2 = document.getElementById('input-green-img');
for(i=0; i<allInputs.length; i++) {
allInputs[i].onkeyup=function(){
var completed = true;
for(y=0; y<allInputs.length; y++) {
if(allInputs[y].value.length === 0) completed = false;
}
if(completed){
button1.style.display = 'none';
button2.style.display = 'block';
} else {
button1.style.display = 'block';
button2.style.display = 'none';
}
};
}
Fiddle
source
share