Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 views
in Technique[技术] by (71.8m points)

html - How to tell browser that the form was wrong and do not save password

I have a website with a login form. My problem is that every time this form is submitted, chrome suggests to save the password, even if it's incorrect

The form:

<form method="POST" action="" id='sign-in'>
  {% csrf_token %}
        
  <div class="form-group inner-addon">
    <input name="txt_login_username" type="text" class="form-control" placeholder="Username">
    <i class="fa fa-user fa-lg fa-fw" aria-hidden="true"></i>
  </div>

  <div class="form-group inner-addon">
    <input name="txt_login_pass" type="password" class="form-control" placeholder="Password">
    <i class="fa fa-key fa-lg fa-fw" aria-hidden="true"></i>
  </div>

  {% for message in messages %}
  <p class='alert alert-danger'>{{ message }}</p>
  {% endfor %}

  <button type="submit" class="btn btn-primary" name="btn_login">Log In</button>
</form>
question from:https://stackoverflow.com/questions/65951061/how-to-tell-browser-that-the-form-was-wrong-and-do-not-save-password

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I figured it out with the help of @deceze. just need to add state=400 to the render method:

render(request, 'index.html', context, status=400)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...