Use autofocus html attribute instead of javascript
authorMagnus Hagander <magnus@hagander.net>
Thu, 20 Dec 2018 14:34:29 +0000 (15:34 +0100)
committerMagnus Hagander <magnus@hagander.net>
Thu, 20 Dec 2018 16:18:11 +0000 (17:18 +0100)
templates/account/login.html

index 7402a966951456faf2dfbecd588b3bc2ac3dd072..a844b81aadb67de84ad38267fcbd62801924343f 100644 (file)
@@ -32,7 +32,7 @@ password, you can use the <a href="/account/reset/">password reset</a> form.
 {%endif%}
 <form action="." method="post" id="login-form">{% csrf_token %}
   <div class="form-group">
-    <input type="text" class="form-control" name="username" id="id_username" placeholder="Username" />
+    <input type="text" class="form-control" name="username" id="id_username" placeholder="Username" autofocus />
   </div>
   <div class="form-group">
     <input type="password" class="form-control" name="password" id="id_password" placeholder="Password"/>
@@ -51,9 +51,4 @@ password, you can use the <a href="/account/reset/">password reset</a> form.
 {%endfor%}
 {%endif%}
 
-
-<script type="text/javascript">
-document.getElementById('id_username').focus()
-</script>
-
 {%endblock%}