From 3997dc14af46608894bc2f174ce0b40468b874cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20FAMIBELLE-PRONZOLA?= Date: Mon, 31 May 2021 20:34:25 +0200 Subject: [PATCH] Add enter key up to valid form login --- components/soumet/koneksyon.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/soumet/koneksyon.js b/components/soumet/koneksyon.js index 7eba4e6..339cf6f 100644 --- a/components/soumet/koneksyon.js +++ b/components/soumet/koneksyon.js @@ -37,6 +37,10 @@ function Koneksyon() { } const handleClick = async () => { + if (!validateEmail(credentials.username) || credentials.password === '') { + return + } + setLoading(true) const response = await signIn('credentials', { redirect: false, @@ -78,6 +82,12 @@ function Koneksyon() { event.preventDefault() } + const handleKeyUp = event => { + if (event.keyCode === 13) { + handleClick() + } + } + return ( @@ -97,6 +107,7 @@ function Koneksyon() { type='email' id='email' onChange={event => handleUpdate({username: event.target.value})} + onKeyUp={handleKeyUp} /> @@ -119,6 +130,7 @@ function Koneksyon() { } onChange={event => handleUpdate({password: event.target.value})} + onKeyUp={handleKeyUp} />