4545 name =" username"
4646 id =" username"
4747 ref =" usernameInput"
48+ oninput =" setCustomValidity('')"
4849 @keydown.enter =" passwordInput.focus()"
4950 class =
" bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" placeholder =
" [email protected] " required />
5051 </div >
5354 <input
5455 ref =" passwordInput"
5556 autocomplete =" current-password"
57+ oninput =" setCustomValidity('')"
5658 @keydown.enter =" login"
5759 :type =" !showPw ? 'password': 'text'" name =" password" id =" password" placeholder =" ••••••••" class =" bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" required />
5860 <button type =" button" @click =" showPw = !showPw" class =" absolute top-12 right-3 -translate-y-1/2 text-gray-400 dark:text-gray-300" >
@@ -120,6 +122,9 @@ import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbi
120122import { callAdminForthApi , loadFile } from ' @/utils' ;
121123import { useRoute , useRouter } from ' vue-router' ;
122124import { Button , Checkbox } from ' @/afcl' ;
125+ import { useI18n } from ' vue-i18n' ;
126+
127+ const { t } = useI18n ();
123128
124129const passwordInput = ref (null );
125130const usernameInput = ref (null );
@@ -167,9 +172,15 @@ async function login() {
167172 const username = usernameInput .value .value ;
168173 const password = passwordInput .value .value ;
169174
170- if (! username || ! password) {
175+ if (! username) {
176+ usernameInput .value .setCustomValidity (t (' Please fill out this field.' ));
177+ return ;
178+ }
179+ if (! password) {
180+ passwordInput .value .setCustomValidity (t (' Please fill out this field.' ));
171181 return ;
172182 }
183+
173184 if (inProgress .value ) {
174185 return ;
175186 }
@@ -184,7 +195,7 @@ async function login() {
184195 }
185196 });
186197 if (resp .error ) {
187- error .value = resp .error ;
198+ error .value = resp .error ;
188199 } else if (resp .redirectTo ) {
189200 router .push (resp .redirectTo );
190201 } else {
0 commit comments