Skip to content

Commit 34f3188

Browse files
committed
fix money format
1 parent 8e24acc commit 34f3188

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/SimpleInput/index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const SimpleInput = ({
2121
max,
2222
ns,
2323
children,
24-
decimalSeparator = ",",
25-
thousandSeparator = ".",
24+
decimalSeparator = ".",
25+
thousandSeparator = "'",
2626
}) => {
2727
const [isvalid, setisvalid] = useState();
2828
const [localValue, setlocalValue] = useState("");
@@ -72,9 +72,10 @@ const SimpleInput = ({
7272
value = value.replace(regex, "");
7373
console.log(value);
7474
if (thousandSeparator === ".") value = value.replace(/\./g, "");
75+
if (thousandSeparator === ",") value = value.replace(/,/g, "");
76+
if (thousandSeparator === "'") value = value.replace(/'/g, "");
7577
console.log(value, Number(value));
7678

77-
if (thousandSeparator === ",") value = value.replace(/,/g, "");
7879
value = value.replace(/ %/g, "");
7980
updated[event.target.name] = Number(value) || value;
8081
} else if (value && type === "percent1") {

src/SimpleInput/partials/InputTag/index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ const InputTag = ({
1111
autoFocus,
1212
currency,
1313
inputRef,
14-
decimalSeparator = ",",
15-
thousandSeparator = ".",
14+
decimalSeparator = ".",
15+
thousandSeparator = "'",
1616
}) => {
1717
const onNumericValueChange = (e) => {
18+
console.log(e.target.value);
1819
if (e.target.value !== value) {
1920
onChange(e);
2021
}
@@ -36,7 +37,7 @@ const InputTag = ({
3637
suffix={suffix}
3738
name={name}
3839
readOnly={readonly}
39-
onChange={onChange}
40+
onChange={onNumericValueChange}
4041
autoFocus={autoFocus}
4142
/>
4243
);

0 commit comments

Comments
 (0)