prevent form submit

This commit is contained in:
Sebastian 2022-12-22 18:38:21 -03:00
parent 43a543b41f
commit 9fb0e7d0b3
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
5 changed files with 60 additions and 19 deletions

View File

@ -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");
}}
>

View File

@ -74,7 +74,13 @@ export function PaytoWireTransferForm({
if (!pageState.isRawPayto)
return (
<div>
<form class="pure-form" name="wire-transfer-form">
<form
class="pure-form"
name="wire-transfer-form"
onSubmit={(e) => {
e.preventDefault();
}}
>
<p>
<label for="iban">{i18n.str`Receiver IBAN:`}</label>&nbsp;
<input
@ -155,11 +161,12 @@ export function PaytoWireTransferForm({
<p style={{ display: "flex", justifyContent: "space-between" }}>
<input
type="button"
type="submit"
class="pure-button pure-button-primary"
disabled={!!errorsWire}
value="Send"
onClick={async () => {
onClick={async (e) => {
e.preventDefault();
if (
typeof submitData === "undefined" ||
typeof submitData.iban === "undefined" ||
@ -203,7 +210,8 @@ export function PaytoWireTransferForm({
type="button"
class="pure-button"
value="Clear"
onClick={async () => {
onClick={async (e) => {
e.preventDefault();
submitDataSetter((p) => ({
amount: undefined,
iban: undefined,

View File

@ -84,7 +84,13 @@ function RegistrationForm(): VNode {
<h1 class="nav">{i18n.str`Welcome to ${bankUiSettings.bankName}!`}</h1>
<article>
<div class="register-div">
<form class="register-form" noValidate>
<form
class="register-form"
noValidate
onSubmit={(e) => {
e.preventDefault();
}}
>
<div class="pure-form">
<h2>{i18n.str`Please register!`}</h2>
<p class="unameFieldLabel registerFieldLabel formFieldLabel">
@ -144,8 +150,10 @@ function RegistrationForm(): VNode {
<br />
<button
class="pure-button pure-button-primary btn-register"
type="submit"
disabled={!!errors}
onClick={() => {
onClick={(e) => {
e.preventDefault();
if (!username || !password) return;
registrationCall(
{ username, password },
@ -164,7 +172,8 @@ function RegistrationForm(): VNode {
{/* FIXME: should use a different color */}
<button
class="pure-button pure-button-secondary btn-cancel"
onClick={() => {
onClick={(e) => {
e.preventDefault();
setUsername(undefined);
setPassword(undefined);
setRepeatPassword(undefined);

View File

@ -45,7 +45,14 @@ export function WalletWithdrawForm({
if (focus) ref.current?.focus();
}, [focus]);
return (
<form id="reserve-form" class="pure-form" name="tform">
<form
id="reserve-form"
class="pure-form"
name="tform"
onSubmit={(e) => {
e.preventDefault();
}}
>
<p>
<label for="withdraw-amount">{i18n.str`Amount to withdraw:`}</label>
&nbsp;
@ -80,9 +87,10 @@ export function WalletWithdrawForm({
<input
id="select-exchange"
class="pure-button pure-button-primary"
type="button"
type="submit"
value={i18n.str`Withdraw`}
onClick={() => {
onClick={(e) => {
e.preventDefault();
submitAmount = validateAmount(submitAmount);
/**
* By invalid amounts, the validator prints error messages

View File

@ -47,7 +47,13 @@ export function WithdrawalConfirmationQuestion(): VNode {
<h1 class="nav">{i18n.str`Confirm Withdrawal`}</h1>
<article>
<div class="challenge-div">
<form class="challenge-form" noValidate>
<form
class="challenge-form"
noValidate
onSubmit={(e) => {
e.preventDefault();
}}
>
<div class="pure-form" id="captcha" name="capcha-form">
<h2>{i18n.str`Authorize withdrawal by solving challenge`}</h2>
<p>
@ -72,8 +78,9 @@ export function WithdrawalConfirmationQuestion(): VNode {
</p>
<p>
<button
type="submit"
class="pure-button pure-button-primary btn-confirm"
onClick={(e) => {
onClick={async (e) => {
e.preventDefault();
if (
captchaAnswer ==
@ -101,14 +108,15 @@ export function WithdrawalConfirmationQuestion(): VNode {
&nbsp;
<button
class="pure-button pure-button-secondary btn-cancel"
onClick={async () =>
onClick={async (e) => {
e.preventDefault();
await abortWithdrawalCall(
backend.state,
pageState.withdrawalId,
pageStateSetter,
i18n,
)
}
);
}}
>
{i18n.str`Cancel`}
</button>