Input fields are retaining their values after a page refresh, how to prevent that?

后端 未结 2 1276
借酒劲吻你
借酒劲吻你 2020-12-19 17:33
Post Your comment
N
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-19 17:55

    Those values are just auto-filled by the client side (the webbrowser) based on the client history. You need to add autocomplete="off" to the form or the individual input fields for which you'd like to turn it off.

    ...

    or

    ...

    No need for nasty JS hacks which may not work on all environments.

    See also:

    • W3 Web Forms 2.0 specification - autocomplete attribute

    Unrelated to the concrete problem, your HTML structure is far from valid. I'd suggest to pass your page through http://validator.w3.org and fix the errors/warnings accordingly.

提交回复
热议问题