I wonder about semantics of <form>
tag.
Few inputs
In my React application I have some checkbox inputs that filter the displayed data:
<input type="checkbox" name="filter-a" />
<input type="checkbox" name="filter-b" />
<input type="checkbox" name="filter-c" />
It's done:
- Without a submit button - filtering logic is triggered on toggling each checkbox
- No request to the server is made - the whole filtering logic is done in the browser's JavaScript
Question
Is it recommended/valid to wrap those inputs in a <form>
element?
<form>
<input type="checkbox" name="filter-a" />
<input type="checkbox" name="filter-b" />
<input type="checkbox" name="filter-c" />
</form>
I'm not asking about the functionality (it works without it), but about the semantics.
Doubts
I have my doubts, because this form does not make any submission nor makes any request. MDN documentation on <form>
says:
The HTML element represents a document section containing interactive controls for submitting information.
I can still see how I can treat firing form logic on each checkbox toggle as submission. I just wonder what the official semantics and guidelines are.