Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
170 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 Reply

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...