Are <input> fields without a name attribute

2020-04-13 11:20发布

Lets say I have two input fields inside a form, like so.

<form class="my-form" method="POST" action="/my/receiver">
    <input id="input1" name="inputfield1" />
    <input id="input2" placeholder="More input" />

    <input type="submit" value="Submit form" />
</form>

If I am running a server that will listen to a form submission on that link, I know for a fact that #input1 will be sent to the server as data. However, since #input2 does not have a name, will this be sent to the server?

If you answer yes / no, is this standard HTML/HTTP behavior? Can I rely on this in a production application?

Note: I'm asking this question because I do not want some info sent from my form (due to security and liability reasons), and I want to ensure that it is not sent.

标签: html http
1条回答
走好不送
2楼-- · 2020-04-13 11:48

An input element with no name is never submitted to the server.

That said, <input> is probably the wrong tool for the job if you specifically don't want it sent.

查看更多
登录 后发表回答