let f = document.getElementById('first');
let s = document.getElementById('second');
s.addEventListener('click', function() {
if (f.value == '') {
alert('Заполните первое поле ');
s.value =
}
});
f.addEventListener('keyup', function() {
if (f.value == '') {
s.disabled = true;
}else{
s.disabled = false;
}
});
let first = document.getElementById('firstInput'); //первое поле
let two = document.getElementById('twoInput'); //второе поле
function preventInput(input) {
input.addEventListener('keydown', handler)
}
function unPreventInput(input) {
input.removeEventListener('keydown', handler)
}
function handler(e) {
e.preventDefault();
}
preventInput(two);
first.addEventListener('change', function(e) {
if (e.target.value == '') {
preventInput(two);
} else {
unPreventInput(two);
}
})
if (e.target.value.lenght < N)