When creating a number field like the following: <Textfield type="number" /> on firefox it allows non-numeric values. It works fine in chrome.
When creating a number field like the following: <Textfield type="number" /> it should only allow numeric values.
Steps:
a| Tech | Version |
| ----------- | ------- |
| Material-UI | v4.8.0 |
| React | v 16.12 |
| Browser |Firefox v71|
| TypeScript | 3.7.2 |
| etc. | |
@BjoernRave as a workaround you can do this:
React.useEffect(() => {
document
.querySelector("input[type='number']")
.addEventListener("keypress", evt => {
if (evt.which === 8) {
return;
}
if (evt.which < 48 || evt.which > 57) {
evt.preventDefault();
}
});
}, []);
@mmarkelov okay, didn't know that and also thanks for the workaround, I was almost going crazy :D
Duplicate of #10582
Most helpful comment
@BjoernRave as a workaround you can do this: