mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-01-12 10:34:17 +00:00
Added specific error messages to numeric range field and made character counter field
This commit is contained in:
parent
f9cb3979d8
commit
7413f5e3c9
@ -66,10 +66,10 @@ export default function NumericRangeField({
|
||||
// and a decimal point if needed. For example, 1000 will become 1,000
|
||||
// or 1000.5 will become 1,000.5
|
||||
|
||||
numberString = numberString.replace(/,/g, '');
|
||||
const numberStringNoCommas = numberString.replace(/,/g, '');
|
||||
|
||||
if (numberString) {
|
||||
const parts = numberString.split('.');
|
||||
if (numberStringNoCommas) {
|
||||
const parts = numberStringNoCommas.split('.');
|
||||
const integerPart = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
return parts.length > 1 ? `${integerPart}.${parts[1]}` : integerPart;
|
||||
}
|
||||
@ -91,9 +91,9 @@ export default function NumericRangeField({
|
||||
}
|
||||
const minNumber = schema.minimum;
|
||||
const maxNumber = schema.maximum;
|
||||
let min = formData?.min;
|
||||
const min = formData?.min;
|
||||
const [minValue, setMinValue] = React.useState(min?.toString() || '');
|
||||
let max = formData?.max;
|
||||
const max = formData?.max;
|
||||
const [maxValue, setMaxValue] = React.useState(max?.toString() || '');
|
||||
|
||||
// the text input eventually breaks when the number gets too big.
|
||||
@ -102,7 +102,7 @@ export default function NumericRangeField({
|
||||
|
||||
const onChangeLocal = (nameToChange: any, event: any) => {
|
||||
event.preventDefault();
|
||||
let numberValue = parseNumberString(event.target.value);
|
||||
const numberValue = parseNumberString(event.target.value);
|
||||
// Validate and update the numeric range based on user input
|
||||
if (nameToChange === 'min') {
|
||||
setMinValue(formatNumberString(numberValue?.toString() || ''));
|
||||
|
Loading…
x
Reference in New Issue
Block a user