autofocus for login templates

master
Aevann 2024-02-14 11:57:05 +02:00
parent 05530cbf99
commit 2a308cd559
8 changed files with 10 additions and 8 deletions

View File

@ -791,3 +791,7 @@ function delReport(t, url) {
}
);
}
for (const el of document.getElementsByClassName('autofocus')) {
el.focus()
}

View File

@ -1 +0,0 @@
document.getElementById('2fa_token').focus();

View File

@ -5,7 +5,7 @@
{% block content %}
<div id="login-form">
<form action="/forgot" method="post" class="mt-3">
<label for="username" class="mt-3">Username</label>
<label for="username" class="autofocus mt-3">Username</label>
<input autocomplete="off" class="form-control" id="username" type="text" name="username" required>
<label for="email" class="mt-3">Email</label>
<input type="email" autocomplete="off" class="form-control" id="password" name="email" required>

View File

@ -14,7 +14,7 @@
{%- endset -%}
{% if failed %}{{macros.alert(error_text, true)}}{% endif %}
<form action="/login" method="post" class="mt-md-3" id="login">
<label for="username" class="mt-3">Username or Email Address</label>
<label for="username" class="autofocus mt-3">Username or Email Address</label>
<input autocomplete="off" class="form-control" id="username"
type="text" name="username" required>
<input hidden name="redirect" value="{{redirect}}">

View File

@ -15,10 +15,9 @@
<input hidden name="redirect" value="{{redirect}}">
<input hidden name="time" value="{{time}}">
<input hidden name="hash" value="{{hash}}">
<label for="2fa_token" class="mt-3">Your verification code</label>
<label for="2fa_token" class="autofocus mt-3">Your verification code</label>
<input autocomplete="off" class="form-control" id="2fa_token" name="2fa_token" type="number" pattern="[0-9]" inputmode="numeric" placeholder="6-digit code">
<small><a href="/lost_2fa">Lost your two-factor authentication device?</a></small>
<button type="submit" class="btn btn-primary login w-100 mt-3" id="login_button">Sign in</button>
</form>
<script defer src="{{'js/login_2fa.js' | asset}}"></script>
{% endblock %}

View File

@ -5,7 +5,7 @@
{% block content %}
<div id="login-form">
<form action="/lost_2fa" method="post" class="mt-3">
<label for="username" class="mt-3">Username</label>
<label for="username" class="autofocus mt-3">Username</label>
<input autocomplete="off" class="form-control" id="username" type="text" name="username" required{% if v %} value="{{v.username}}" disabled{% endif %}>
<label for="email" class="mt-3">Password</label>
<input autocomplete="off" class="form-control" id="password" type="password" name="password" required>

View File

@ -7,7 +7,7 @@
<input hidden name="time" value="{{time}}">
<input hidden name="user_id" value="{{v.id}}">
<input hidden name="token" value="{{token}}">
<label for="passentry" class="mt-3">New Password</label>
<label for="passentry" class="autofocus mt-3">New Password</label>
<input autocomplete="off" class="form-control" id="passentry" type="password" minlength="8" maxlength="100" name="password" required>
<label for="confentry" class="mt-3">Confirm New Password</label>
<input autocomplete="off" class="form-control" id="confentry" type="password" minlength="8" maxlength="100" name="confirm_password" required>

View File

@ -67,7 +67,7 @@
{% if redirect %}<input hidden name="redirect" value="{{redirect}}">{% endif %}
{% if ref_user %}<input hidden name="referred_by" value="{{ref_user.id}}">{% endif %}
<label for="username-register" class="mt-3">Username</label>
<label for="username-register" class="autofocus mt-3">Username</label>
<input autocomplete="off" class="form-control" id="username-register" type="text" name="username" pattern="[a-zA-Z0-9_\-]{3,25}" min="3" max="25" required {% if username %}value="{{username}}"{% endif %}>
<small id="usernameHelpRegister"></small>