目前這方法可用
<input type="text" style={{ textAlign: "right" }} maxLength={9} onChange={onlynumber} />
const onlynumber = (e) => { //去掉非數字 e.target.value = e.target.value.replace(/\D/g, ''); //todo anything };參考資料
Create a Numbers only Input field in React.js