Answer the question
In order to leave comments, you need to log in
How to check multiple input fields for text?
There are lines like this:
function check() {
if ($('#zagol').val() != '')
$('#zag').removeAttr('disabled');
else
$('#zag').attr('disabled','disable');
}
Answer the question
In order to leave comments, you need to log in
In your case, it's better to refuse selection by id in favor of class .
If the button, then you can do this.<input type="submit">
<form>
<input type="text" class="checkme" value="zagol">
<!-- Другие элементы формы -->
<input type="submit">
</form>
<form>
<input type="text" class="checkme" value="users">
<!-- Другие элементы формы -->
<input type="submit">
</form>
function check(){
if ($(this).val() !== '') $(this).parent().find('input[type="submit"]').removeAttr("disabled");
else $(this).parent().find('input[type="submit"]').attr('disabled', true);
}
$(".checkme").change(check);
<input type="text" class="checkme">
<button>#Загол</button>
<!-- Другие элементы -->
<input type="text" class="checkme">
<button>#Юзеры</button>
function check(){
if ($(this).val() !== '') $(this).next('button').removeAttr("disabled");
else $(this).next('button').attr('disabled', true);
}
$(".checkme").change(check);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question