I have a disabled element which I enable it only after value was entered to it's previous input, the problem is that change
triggers before the input lost focus and the focus moved to the next not disabled element, so removing the disabled
attribute then is no good.
HTML:
Fill this before you continue: <input id="a" />
Fill this after the previous input: <input id="b" disabled="disabled" />
jQuery:
$('#a').change(function(){
if (this.value === "")
$('#b').attr('disabled', 'disabled');
else
$('#b').removeAttr('disabled');
});
I manged to overcome this problem by changing from disabled
to readonly
but then it's readonly and not disabled as I preferred, are there good and robust(mouse proof) ways to achieve it and using readonly
?
Things to consider:
- Subscribing to multiple events doesn't really seems right.
- The user can paste text to the 1st input without using keyboard at all.