File tree Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Original file line number Diff line number Diff line change 11{
22 "cSpell.words" : [
3+ " instanceof" ,
4+ " onfocus" ,
35 " sveltejs"
46 ]
57}
Original file line number Diff line number Diff line change 11<script lang =" ts" >
2+ import { onMount } from ' svelte'
23 import type { ActionData } from ' ./$types'
34
45 export let form: ActionData
6+
7+ let username_element: HTMLInputElement
8+
9+ onMount (() => {
10+ document .onfocus = (event ) => {
11+ if (event .target instanceof HTMLInputElement ) event .target .select ()
12+ }
13+
14+ username_element .select ()
15+ })
516 </script >
617
718<h1 >Log in</h1 >
819
920<form method =" POST" >
10- <input type ="text" name ="username" placeholder ="Username" required value ={form ?.username ?? ' ' } />
21+ <input
22+ type =" text"
23+ name =" username"
24+ placeholder =" Username"
25+ required
26+ value ={form ?.username ?? ' ' }
27+ bind:this ={username_element }
28+ />
1129 <input type =" password" name =" password" placeholder =" Password" required />
1230
1331 {#if form ?.missing }<p class ="error" >Username and password is required.</p >{/if }
Original file line number Diff line number Diff line change 11<script lang =" ts" >
2- import type { ActionData } from ' ./$types' ;
2+ import { onMount } from ' svelte'
3+ import type { ActionData } from ' ./$types'
34
4- export let form: ActionData ;
5+ export let form: ActionData
6+
7+ let username_element: HTMLInputElement
8+
9+ onMount (() => {
10+ document .onfocus = (event ) => {
11+ if (event .target instanceof HTMLInputElement ) event .target .select ()
12+ }
13+
14+ username_element .select ()
15+ })
516 </script >
617
718<h1 >Register</h1 >
819
920<form method =" POST" >
10- <input type ="text" name ="username" placeholder ="Username" required value ={form ?.username ?? ' ' } />
21+ <input
22+ type =" text"
23+ name =" username"
24+ placeholder =" Username"
25+ required
26+ value ={form ?.username ?? ' ' }
27+ bind:this ={username_element }
28+ />
1129 <input type ="email" name ="email" placeholder ="email" required value ={form ?.email ?? ' ' } />
1230 <input type =" password" name =" password" placeholder =" Password" required />
1331
You can’t perform that action at this time.
0 commit comments