Есть форма с логином и паролем. Поле с паролем закрыто и должно открыться после ввода 5 символов в поле с логином, а кнопка входа открыться после заполнения 5 символов в поле логина и пароля. Как это организовать на js (jquery)?
Можно так:
function checkCount() {
$("#password").attr("disabled", true)
$("#button").attr("disabled", true)
if ($("#login").val().length > 5) {
$("#password").removeAttr("disabled")
if ($("#password").val().length > 5) {
$("#button").removeAttr("disabled")
}
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" name="login" id="login" placeholder="Login" onkeydown="checkCount()" onkeyup="checkCount()">
<input type="text" name="password" id="password" placeholder="Password" onkeydown="checkCount()" onkeyup="checkCount()" disabled="disabled">
<button id="button" disabled="disabled">Submit</button>
$(function() {
$(document).on('input', 'input[type="text"]', function() {
if ($(this).val().length > 5) {
$('input[type="password"]').removeAttr('disabled');
} else {
$('input[type="password"]').attr('disabled', 'disabled');
}
});
$(document).on('input', 'input[type="password"]', function() {
if ($(this).val().length > 5) {
$('input[type="submit"]').removeAttr('disabled');
} else {
$('input[type="submit"]').attr('disabled', 'disabled');
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
<input type="text">
<input type="password" disabled>
<input type="submit" disabled>
</form>
Апостиль в Лос-Анджелесе без лишних нервов и бумажной волокиты
Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости