Можете ли вы помочь? HTML и JavaScript ниже -< /p>
html -< /p>
Upload Avatar
Drag and drop or click to upload
Remove image
Change image
Upload your photo (JPG or PNG, max size: 500KB).
Full Name
Email Address
GitHub Username
Generate My Ticket
< /code>
js -< /p>
form.addEventListener("submit", (e) => {
e.preventDefault();
const isEmail = /^.+@.+$/.test(emailAddress.value);
let messages = [];
let messagesTwo = [];
if ((firstName.value === "") | (firstName.value == null)) {
messages.push("name is required");
}
if (messages.length > 0) {
errorElement.innerText = messages.join(" , ");
}
if (!isEmail) {
messagesTwo.push("Email is formatted incorrectly.");
}
if (messagesTwo.length > 0) {
errorElementEmail.innerText = messagesTwo;
}
document.getElementById("tg-form").submit();
});
< /code>
Я попытался удалить функцию отправки внизу, но моя форма вообще не отправляется. Мои сообщения об ошибках появляются, если я оставлю соответствующие поля ввода пустыми, но форма все еще отправляется, чего не должно происходить, и я понятия не имею, что делаю не так.>
Подробнее здесь: https://stackoverflow.com/questions/796 ... default-on
Мобильная версия