I have 2 text inputs on a Form:
<div class="form-group">
<input type="text" class="form" id="descriptionInput" placeholder="Customer Name" onkeyup="manage(this)">
</div>
<div class="form">
<input type="text" class="form" id="contactName" placeholder="Contact Name">
</div>
The idea is to enable the submit button only if these 2 fields have any value: My button:
<button type="submit" id="btSubmit" disabled>Add new Customer Entry</button>
My enable/disable function:
function manage(descriptionInput, contactName) {
var bt = document.getElementById('btSubmit');
var custName = document.getElementById('descriptionInput').value.length;
var contact = document.getElementById('contactName').value.length;
if (custName > 0 && contact > 0) {
bt.disabled = false;
}
else {
bt.disabled = true;
}
}
Issue is: if customer name field has 1 character only + contact has 1 or more characters = doesn't work if customer name field has 2 characters + contact has 1 or more characters = it works
Not sure what's happening, any ideas? Thanks