Disable saving the form field in the browser, autocomplete

I am trying to disable the autocomplete function in the browser and set the autocomplete = "off" attribute to Input. I tried using the code below, but it does not put autocomplete = "off" in the generated html input tag. What is the right way to do this?

   @Html.EditorFor(model => model.ConfirmPassword, new { autocomplete = "off" })
+3
source share
2 answers

@Html.EditorFordoes not accept object htmlAttributesas the second argument (or any argument in this regard).

Try instead @Html.TextBoxFor:

 @Html.TextBoxFor(model => model.ConfirmPassword, new { autocomplete = "off" })
+7
source
<form name="form1" id="form1" method="post" autocomplete="off" 
  action="http://www.example.com/form.cgi">
+3
source

All Articles