const [inputNum, setInputNum] = useState("");
const REGEX_NUMBER = /^[0-9]*$/g;
export const onChangeFilterNumber = (event, setterFunction) => {
let input = event.target.value;
if (input.match(REGEX_NUMBER)) {
setterFunction(input);
return true;
} else {
return false;
}
};
...
...
{/* type="number"にすると"e","E"が入力できてしまう挙動になりハマった */}
<input
type="text"
value={inputNum}
onChange={changeEvent => onChangeFilterNumber(changeEvent, setInputNum)}
placeholder="半角数字で入力してください"
/>
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme