Let's say I have a form like this:
<form id="something_form">
<input type="text" id="thing1" name="thing1">
<input type="hidden" id="thing2" name="thing2">
<input type="text" id="secret" name="secret">
<input type="submit">
</form>
Currently I have JS that listens for the submission event, takes the info in the secret input, and does some work before adding it to thing2. The server never uses or needs secret. I can clear the data in secret before form submission, so it's just thing1=abc&thing2=abc&secret=, however if the user has JS off, then the form submission request would have thing1=abc&thing2=&secret=secret.
Is there a pure HTML way to make an input work as normal, but not get serialized/submitted on form submission? I know that I can remove name="secret" to achieve this, but that loses me any functionality that relies on the name attribute.
My idea for a solution is to render the page without the name="secret":
<input type="text" id="secret">
then add it via JS(since if the user has JS on, it would run):
document.getElementById("secret").setAttribute("name", "secret");
But I'm curious if there's another solution for this.