Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
Resolves #318, makes sure no text can be entered when in numbersOnly …
Browse files Browse the repository at this point in the history
…mode
  • Loading branch information
Portals committed Mar 3, 2020
1 parent 4af1290 commit cb6e70d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/elements/digit-text-field/DigitTextField.element.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ const DigitTextField = ({
onKeyPress
}) => {
const handleOnChange = (e, maxLength, onChange) => {
const newValue = e.target.value;
var newValue = e.target.value;
if (maxLength === -1 || newValue.length <= maxLength) {
if (numbersOnly) {
newValue = newValue.replace(/[^0-9]/g, "");
}

onChange(e);
}
};
Expand Down

0 comments on commit cb6e70d

Please sign in to comment.