1

I have two different forms on my home page: one for logins and one for registrations. As you can see from the code, the forms have inputs with different names:

<h3> Log In </h3>
<form action="/login/" method="POST" class="form-vertical" style="padding-top: 5px">
  <input id="id_login_username" type="text" name="login_username" maxlength="25" />
  <input type="password" name="login_password" id="id_login_password" /><br>
  <button type="submit" class="btn btn-info">Login</button>
</form>

<h3> Sign Up <small>(It's free!)</small></h3>
<form action="/register/" method="POST" class="form-vertical" style="padding-top: 5px">
  <input id="id_register_username" type="text" name="register_username" maxlength="25" />
  <input type="text" name="register_email" id="id_register_email" />
  <input type="password" name="register_password" id="id_register_password" />
  <input type="password" name="register_password2" id="id_register_password2" /><br>
  <button type="submit" class="btn">Submit</button>
</form>

Which renders to this in Chrome:

enter image description here

What can be causing this? And how can I fix it?

2 Answers 2

7

That's a really good question and I'm sorry to say I have no idea. Did you try to register once and also login at least once? If so, that "might" be what's causing it as browsers come complete with the "autoremember" feature.

Assuming autofill is enabled (it is by default), the reason it autofills the rest is because chrome's autofill server works on regular expressions, not exact matches.

All the regular expressions used for the various fields can be found in autofill_regex_constants.cc.utf8.

From there you can see that the expression for email field is "e.?mail" and for username it is "user.?name|user.?id|nickname|maiden name|title|prefix|suffix"

0
3

It appears a similar question has been asked before:

What is the correct way to stop form input boxes auto-completing?

There is an autocomplete attribute you can use in form fields.

<input id="id_login_username" type="text" name="login_username" maxlength="25" autocomplete="off" />
2
  • Awesome, I'm going to give that a try (and figure out how to do it within Django forms). However, do you know WHY this is happening? The inputs have different names so why is Chrome filling it out?
    – user623990
    Apr 28, 2012 at 2:21
  • That's a really good question and I'm sorry to say I have no idea. Did you try to register once and also login at least once? If so, that "might" be what's causing it as browsers come complete with the "autoremember" feature.
    – Minja
    Apr 28, 2012 at 2:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.