Skip to content

fix(money-input): add check for leading zeros #1255

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/money-input/money-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ export class MoneyInput extends React.PureComponent<MoneyInputProps, MoneyInputS
};

private handleChange = (value) => {
// если значение начинается с нуля, то следом за ним может быть только десятичный разделитель
if (/^0\d+/.test(value)) {
return;
}

this.setState({ value });

if (this.props.onChange) {
Expand Down