UNPKG

@xyo-network/react-shared

Version:

Common React library for all XYO projects that use React

12 lines (11 loc) 412 B
/** * Format a raw input string (i.e. Change event from input type=text) * Designed to filter out non-digits and extra decimals **/ export const formatBigIntInput = (rawValue: string) => { // remove all alpha characters but allow decimals const filteredValue = rawValue.replaceAll(/[^\d.]/g, '') // only allow one decimal point if (filteredValue.split('.').length > 2) return return filteredValue }