I have two inputs where one is disabled and alt tag is removed if user adds anything into another input. This part works fine. But i also want to disable this same input if value is predefined in first input. Sometimes first input is empty and user has to fill it, sometimes it has predefined value, so another input should be disabled and alt tag removed.
Tnx
$('.gsmhr').on('input', function() {
if ($(this).val().length)
$('.gsmslo1').prop('disabled', true).val('').removeAttr("alt");
else $('.gsmslo1').prop('disabled', false);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
This works on user input<br>
<input type="text" name="" value="" class="gsmhr" maxlength="15" size="17" />
<input type="text" name="" value="" class="gsmslo1" alt="simple" maxlength="3" size="1" />
<br><br>
This should work if value is predefined<br>
<input type="text" name="" value="asdf" class="gsmhr" maxlength="15" size="17" />
<input type="text" name="" value="" class="gsmslo1" alt="simple" maxlength="3" size="1" />