From 961517684d964c2422c5744799c2c45eb7061b37 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Fri, 24 Nov 2023 10:40:03 +0100 Subject: [PATCH] Added a security check to the Input.jsx --- client/src/pages/Join/states/Input/Input.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/src/pages/Join/states/Input/Input.jsx b/client/src/pages/Join/states/Input/Input.jsx index 9b8b287..0950b35 100644 --- a/client/src/pages/Join/states/Input/Input.jsx +++ b/client/src/pages/Join/states/Input/Input.jsx @@ -11,6 +11,10 @@ export const Input = ({setState, capital, setCost, setWin, settings}) => { const [error, setError] = useState(""); + const validate = (e) => { + return !(e.target.value.toString().includes(",") || e.target.value.toString().includes(".")); + } + const submit = () => { if ((settings.costPerCake * amount + settings.costPerRound) > capital) { setError("Zu wenig Kapital"); @@ -51,12 +55,12 @@ export const Input = ({setState, capital, setCost, setWin, settings}) => {

Preis

e.target.value <= settings.maxPrice && setPrice(e.target.value)} value={price}/> + onChange={(e) => e.target.value <= settings.maxPrice && validate(e) && setPrice(e.target.value)} value={price}/>

Absatzmenge

e.target.value <= settings.maxProduction && setAmount(e.target.value)} value={amount}/> + onChange={(e) => e.target.value <= settings.maxProduction && validate(e) && setAmount(e.target.value)} value={amount}/>