Hanya angka atau string. Bidang Input di React

onKeyPress={(e) => !/[0-9]/.test(e.key) && e.preventDefault()} // numbers only

onKeyPress={(e) => !/[a-zA-z]/.test(e.key) && e.preventDefault()} // alphabets only.
Jolly Jay