FormsLesson 150Free preview
Empty Input Validation
This lesson is part of How To · All levels
Summary
This lesson discusses how to make sure that the input column is not sent in an empty state. The checks can take advantage of the required attributes of the built-in HTML or be done manually with JavaScript before the form is sent. Feedback should be clear, point to problematic columns, and still support validation on the server.
Key points
- Attributes required to validate a blank in-built without additional JavaScript
- Use trim() to make the input that only contains spaces considered empty
- Mark the problem column with the invalid aria and display the message connected to the input
- Stop submitting the form with pre-Default only when the data is completely invalid
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.