From cf6416ae99aaba26857bc63f1bbe26954d312efa Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 10 Feb 2021 11:14:00 +0100 Subject: added form submission on enter --- pages/login.tsx | 30 ++++++++++++++++++------------ pages/register.tsx | 13 ++++++++----- 2 files changed, 26 insertions(+), 17 deletions(-) (limited to 'pages') diff --git a/pages/login.tsx b/pages/login.tsx index 86066e6..9df9490 100644 --- a/pages/login.tsx +++ b/pages/login.tsx @@ -1,10 +1,13 @@ import axios from 'axios'; +import { FormEvent } from 'react'; import { NavBar } from '../components/navbar'; import { CenteredPage } from '../components/page'; import { Vierkant, Input, Button } from '../components/ui'; -function submitLogin() { +function submitLogin(event?: FormEvent) { + event.preventDefault(); + var formData = { email: (document.getElementById("email") as HTMLInputElement).value, password: (document.getElementById("password") as HTMLInputElement).value @@ -45,17 +48,20 @@ export default function LoginPage() { textAlign: "center" }}> - - -
- - -
+
+ + +
+ + +
+ +
diff --git a/pages/register.tsx b/pages/register.tsx index 4940580..b9b8325 100644 --- a/pages/register.tsx +++ b/pages/register.tsx @@ -1,12 +1,14 @@ +import axios from 'axios'; +import { validate as validateEmail } from 'email-validator'; +import { FormEvent } from 'react'; + import { NavBar } from '../components/navbar'; import { CenteredPage } from '../components/page'; import { Vierkant, Input, Button } from '../components/ui'; -import { v4 as uuidv4 } from 'uuid'; -import { validate as validateEmail } from 'email-validator'; -import axios from 'axios'; +function submitRegister(event?: FormEvent) { + event.preventDefault(); -function submitRegister() { var formData = { username: (document.getElementById("username") as HTMLInputElement).value, email: (document.getElementById("email") as HTMLInputElement).value, @@ -78,11 +80,12 @@ export default function RegisterPage() { textAlign: "center" }}> -
+ +
-- cgit v1.2.3