Skip to content

ux: Implement strict number-only masking for the token amount input #88

@AlAfiz

Description

@AlAfiz

Description

HTML type="number" inputs still allow users to type characters like "e" (exponent), "+", and "-", which breaks our swap math.
If a user pastes text or invalid characters into the amount field, the app calculates NaN and crashes.
We need to implement a strict input mask or regex filter that absolutely prevents anything other than numbers and a single decimal point from being entered.
This bulletproofs the UI against formatting bugs.

Requirements

  • Update the onChange handler inside the TokenInput.tsx component.
  • Write a regex filter (e.g., /^[0-9]*\.?[0-9]*$/) to validate the raw string value.
  • If the new value doesn't match the regex, return early and do not update the React state.
  • Ensure users can still cleanly delete numbers and type decimal values like 0.55.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions