In HTML5 we can do <input type="text" maxlength="3" />
but how do I same in Material-UI ? Bellow is example Material-UI TextFiled component
<TextField
id="name"
label="Name"
type="string"
//maxLength="3" Or maxlength="3" Or max="3"
margin="normal"
/>
Add the inputProps
to the TextField
example following:
<TextField
inputProps={{
maxLength: 10,
}}
/>
Or alternative hard coded solution:
<TextField
onInput={e => {
e.target.value = Math.max(0, parseInt(e.target.value)).toString().slice(0, 12);
}}
/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.