add negative handler on amount field

This commit is contained in:
Wikzyy
2025-04-30 16:49:36 +07:00
parent 0c1dc54262
commit 27d95959f0
2 changed files with 15 additions and 3 deletions

View File

@ -263,10 +263,16 @@ const TransactionDisbursement = () => {
<label htmlFor="amount">Amount</label>
<span className="text-red-500">*</span>
<Input
id="amount"
id="topupAmount"
type="number"
min={0}
value={form.amount}
onChange={(e) => setForm({ ...form, amount: e.target.value })}
onChange={(e) => {
const value = Number(e.target.value);
if (value >= 0) {
setForm({ ...form, amount: String(value) });
}
}}
/>
</div>
<div>

View File

@ -158,8 +158,14 @@ const TransactionTopup = () => {
<Input
id="topupAmount"
type="number"
min={0}
value={form.topupAmount}
onChange={(e) => setForm({ ...form, topupAmount: e.target.value })}
onChange={(e) => {
const value = Number(e.target.value);
if (value >= 0) {
setForm({ ...form, topupAmount: String(value) });
}
}}
/>
</div>
<div>