Tomas
Tomas

Reputation: 18127

disable form field saving in browser, autocomplete

I am trying to disable autocomplete feature in browser and put autocomplete="off" attribute on Input. I have tried to use code below but it do not put autocomplete="off" on generated Input html tag. What is the correct way to do this?

   @Html.EditorFor(model => model.ConfirmPassword, new { autocomplete = "off" })

Upvotes: 3

Views: 3471

Answers (2)

Ahsan Ashfaq
Ahsan Ashfaq

Reputation: 293

<form name="form1" id="form1" method="post" autocomplete="off" 
  action="http://www.example.com/form.cgi">

Upvotes: 3

Sergi Papaseit
Sergi Papaseit

Reputation: 16204

@Html.EditorFor doesn't take an object htmlAttributes as a second argument (or any argument for that matter).

Try using @Html.TextBoxFor instead:

 @Html.TextBoxFor(model => model.ConfirmPassword, new { autocomplete = "off" })

Upvotes: 7

Related Questions