I want my TextField to accept only the values from 0-9 and letters A-F. Thanks.
<TextField
id="text-field-1"
placeholder="Enter text"
type="text"
value={state.alphanum}
onChange={(event) => {
const regex = /^([a-z0-9]){minLength,maxLength}$/i;
if (event.target.value === '' || regex.test(event.target.value)) {
setState({ ...state, alphanum: event.target.value });
}
}}
variant="outlined" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With