diff --git a/src/pages/superadmin/header/InviteModal.tsx b/src/pages/superadmin/header/InviteModal.tsx index 9175d089..0f96946d 100644 --- a/src/pages/superadmin/header/InviteModal.tsx +++ b/src/pages/superadmin/header/InviteModal.tsx @@ -81,6 +81,14 @@ const InviteModal = (props: InviteProps) => { setLoading(false); }; + function handleNumberChange(e: any, updateState: (value: number) => void) { + const { value } = e.target; + + // Validate: Allow only numbers + if (/^\d*$/.test(value)) { + updateState(Number(value)); + } + } return ( <> { width: '100%' }} value={inviteNumber} - onChange={(e: any) => setInviteNumber(Number(e.target.value))} + onChange={(e: any) => handleNumberChange(e, setInviteNumber)} /> @@ -160,12 +168,12 @@ const InviteModal = (props: InviteProps) => { setSatAmount(Number(e.target.value))} + onChange={(e: any) => handleNumberChange(e, setSatAmount)} />