Я не хочу делать это на модели, помещая эти DataAnnotations
Поэтому у меня есть такая форма
Код: Выделить всё
Save
Код: Выделить всё
function validateForm(event) {
const form = document.getElementById('MyForm');
let textAreas = form.querySelectorAll('textarea');
let allFilled = true;
for (let i = 0; i < textAreas.length; i++) {
if (textAreas[i].value.trim() === "") {
allFilled = false;
break;
}
}
if (!allFilled) {
alert("All the Requirements are required.");
event.preventDefault();
return false;
}
return true;
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... javascript
Мобильная версия