From 9fb0e7d0b386a1b10a39d0b664131590cd0c3a68 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Thu, 22 Dec 2022 18:38:21 -0300
Subject: prevent form submit

---
 packages/demobank-ui/src/pages/LoginForm.tsx | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

(limited to 'packages/demobank-ui/src/pages/LoginForm.tsx')

diff --git a/packages/demobank-ui/src/pages/LoginForm.tsx b/packages/demobank-ui/src/pages/LoginForm.tsx
index 0acced4ab..dd0364d6e 100644
--- a/packages/demobank-ui/src/pages/LoginForm.tsx
+++ b/packages/demobank-ui/src/pages/LoginForm.tsx
@@ -44,7 +44,13 @@ export function LoginForm(): VNode {
 
   return (
     <div class="login-div">
-      <form action="javascript:void(0);" class="login-form" noValidate>
+      <form
+        class="login-form"
+        noValidate
+        onSubmit={(e) => {
+          e.preventDefault();
+        }}
+      >
         <div class="pure-form">
           <h2>{i18n.str`Please login!`}</h2>
           <p class="unameFieldLabel loginFieldLabel formFieldLabel">
@@ -87,10 +93,11 @@ export function LoginForm(): VNode {
           />
           <br />
           <button
-            type="button"
+            type="submit"
             class="pure-button pure-button-primary"
             disabled={!!errors}
-            onClick={() => {
+            onClick={(e) => {
+              e.preventDefault();
               if (!username || !password) return;
               loginCall({ username, password }, backend);
               setUsername(undefined);
@@ -103,7 +110,8 @@ export function LoginForm(): VNode {
           {bankUiSettings.allowRegistrations ? (
             <button
               class="pure-button pure-button-secondary btn-cancel"
-              onClick={() => {
+              onClick={(e) => {
+                e.preventDefault();
                 route("/register");
               }}
             >
-- 
cgit v1.2.3

