I am trying to keep an input disabled until 2 inputs have atleast 4 characters. The closest I was able to find on SO was a user settling for 8 characters total but this would allow for one of the inputs to be blank in the other had over 8. Here is what I have tried:
Without on()
$('#ancestor input').keyup(function(){
var foo = $('input[name=foo]').val();
var bar = $('input[name=bar]').val();
if(foo.length > 4 && bar.length > 4){
$('#some-button').prop('disabled', false);
}else{
$('#some-button').prop('disabled', true);
}
});
With on()
$('#ancestor input').on('keyup',function(){
var foo = $('input[name=foo]').val();
var bar = $('input[name=bar]').val();
if(foo.length > 4 && bar.length > 4){
$('#some-button').prop('disabled', false);
}else{
$('#some-button').prop('disabled', true);
}
});
Interestingly I can console.log(foo.length) and console.log(bar.length) and see both lengths ticking up just fine with each keyup.
At least 4 charactersso should be>= 4. Now, what is your issue???>3instead of>4? jsfiddle.net/9woyctz2>3for atleast four chars