Automatically focus on email input on login page
MODIFY
resources/assets/js/app.js
resources/assets/js/app.js
@@ -44,5 +44,13 @@ Vue.directive('click-outside', {
})
const app = new Vue({
- el: '#app'
+ el: '#app',
+
+ mounted() {
+ let input = document.querySelector('[autofocus]');
+
+ if (input) {
+ input.focus()
+ }
+ }
})

MODIFY
resources/views/login.blade.php
resources/views/login.blade.php
{{ csrf_field() }}
<div class="input">
<label>E-mail</label>
- <input type="email" name="email" value="{{ old('email') }}" class="shadow" />
+ <input type="email" name="email" value="{{ old('email') }}" class="shadow" autofocus />
</div>
<div class="input">
<label>Password</label>

Automatically focus on email input on login page