0

I'm trying to disable autocomplete in two password fields but i couldn't do it. It worked fine with the "autocomplete = off" on textboxes but it didn,t work on password fields. Thank you in advance.

 <div class="form-group" autocomplete="new-password">
    @Html.LabelFor(m => m.Password, new { @class = "col-md-5 control-label" })
    <div class="col-md-5">

        @Html.PasswordFor(m => m.Password, new { @Title = Password, @class = "form-control", @autocomplete = "new-password" })
    </div>
</div>
<div class="form-group" autocomplete="new-password">
    @Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-5 control-label" })
    <div class="col-md-5">
        @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control", @autocomplete = "new-password" })
    </div>
</div>
<div class="form-group">
    <div class="col-md-offset-2 col-md-5">
        <input type="submit" class="btn btn-default" value="Confirmer" />
    </div>
</div>
Hedi Jl
  • 29
  • 7

1 Answers1

0

You can try this.

  1. Use a tag for the all html elements as a root. And use autocomplete="off" onto that tag.

  2. Then add hidden with autocomplete="false" as a first children element of the form.

If this is not working, feel free to ask for that.

Look for a example : https://gist.github.com/niksumeiko/360164708c3b326bd1c8

Mohan Perera
  • 370
  • 1
  • 4
  • 15