How to trigger a message about the invalid form field?
There is a text input with a required attribute that is outside of the form. Is it realistic to trigger a browser error message on it when a button is pressed? Googled the .checkValidity () method, but it doesn't work if the field has no form.
Simply. Yuzai. Form. It doesn't matter if it is sent to the server, it won't. It does not matter. If there are text fields, always use the form . So you save yourself and the user a ton of headaches (like the one described in the question).
A form is an interactive element (like a button, link, etc.). The user can interact with it in many ways, not only by pressing the bear into a button not far away. For example, everyone is familiar with the behavior, especially when there is only one text field: enter something and press Enter. Without a form, this will not work and you will have to be additionally confused for keyboard tracking and so on.Anonymous
To place the code, please use CodePen or similar tool. Thanks you!