Kaustubh Maladkar• 230
@KaustubhMaladkar
Posted
Hi Ayodelearog,
- To provide error messages, include a paragraph in your HTML whose
display
property is set tonone
. Upon submission, you can choose to display to these paragraphs. - To prevent the submission of empty field, add the required attribute, e.g.
<input type="text" required>
. You should also perform a check in JavaScript, like this
form.addEventListener("submit", e => {
if (input.value == "") {
e.preventDefault();
input..classList.add("error") //your error class should include the error styles in CSS
}
}
1