Mám problém, chci, aby poslal formulář, když textarea mít min. délka 20 char, ale můj kód, ne pracovní. Pokaždé, když stisknete tlačítko, vrátí false Chci ten kód dont poslat, když okno načíst a textarea délka se rovná 0
const message = document.querySelector('#message');
const btn = document.querySelector('.btn');
f = false;
t = true;
const blockBtn = (b) => {
btn.addEventListener('click', e => {
console.log(b);
e.returnValue = b;
// console.log(e.returnValue);
});
}
const textArea = function (event) {
const length = this.value.length;
console.log(length);
if (length < 20 || length == null) {
blockBtn(f);
} else {
console.log('dziala')
blockBtn(t);
};
}
const textAreaWindow = () => {
const messageValueLength = message.value.length;
if (messageValueLength == 0) {
blockBtn(f);
}
}
message.addEventListener('input', textArea);
window.addEventListener('load', textAreaWindow);