According to the html specification, a field is sent if it meets the following criteria:
- It is contained in the form
- This is the input type, selection, button
- It contains a nonempty name attribute.
- If it is set to <input type = "checkbox" or type = "radio" / ">, it should be checked.
Visibility doesnโt matter. There are actually many reasons why something may be invisible, not to mention being off-screen. Some methods, such as honeypot fields, require this.
So, in order to fully answer your question, if some form interaction requires that you submit only what is visible, you can do one of the following:
- Move the "visible" elements as children of the form (the preferred path), moving them to another parent when they are not visible (after the animation hides them). This should be the easiest, especially if I use jquery. Remember the animation, move the hidden elements around their respective parents, and then live. In addition, hidden elements can be easily manipulated with minimal performance, as the browser does not try to re-display them until they become visible in any case.
- Clear data (lose user input)
- Clear the names of the input fields and recreate the names when they are not hidden.
The third method is a bit. I would do the first or second, depending on your specific needs, with the preference given to the first.
source share