Add enter key up to valid form login

This commit is contained in:
Cédric FAMIBELLE-PRONZOLA
2021-05-31 20:34:25 +02:00
parent d37f901e93
commit 3997dc14af
+12
View File
@@ -37,6 +37,10 @@ function Koneksyon() {
} }
const handleClick = async () => { const handleClick = async () => {
if (!validateEmail(credentials.username) || credentials.password === '') {
return
}
setLoading(true) setLoading(true)
const response = await signIn('credentials', { const response = await signIn('credentials', {
redirect: false, redirect: false,
@@ -78,6 +82,12 @@ function Koneksyon() {
event.preventDefault() event.preventDefault()
} }
const handleKeyUp = event => {
if (event.keyCode === 13) {
handleClick()
}
}
return ( return (
<Container maxWidth='sm'> <Container maxWidth='sm'>
<Box align='center'> <Box align='center'>
@@ -97,6 +107,7 @@ function Koneksyon() {
type='email' type='email'
id='email' id='email'
onChange={event => handleUpdate({username: event.target.value})} onChange={event => handleUpdate({username: event.target.value})}
onKeyUp={handleKeyUp}
/> />
</FormControl> </FormControl>
@@ -119,6 +130,7 @@ function Koneksyon() {
</InputAdornment> </InputAdornment>
} }
onChange={event => handleUpdate({password: event.target.value})} onChange={event => handleUpdate({password: event.target.value})}
onKeyUp={handleKeyUp}
/> />
</FormControl> </FormControl>