New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TextField] How to set maxLength? #1578
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@JarLowrey answered it here: #5309 (comment) For the reference I mention it here too. To limit the number of input length 'e.g. 10' in <TextField
inputProps={{
maxLength: 10,
}}
/> |
Note that <TextField
InputProps={{
disableUnderline: true
}}
inputProps={{
maxLength: 10
}}
/> |
In the same way min length property also works right? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Note that if an |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I want to use Example: const [deposit, setDeposit] = React.useState<number | null>(null);
const disabled = deposit == null || deposit < 0 || deposit === 0;
return (
<TextField
variant='outlined'
color='primary'
fullWidth
type='number'
value={deposit}
onChange={(e) => setDeposit(Number(e.target.value.substring(0, 6)))} // This line to limit the length!
label='Deposit'
InputProps={{
endAdornment: (
<InputAdornment position='end'>
<Button
variant='text'
disabled={disabled}
color={'primary'}
onClick={(_) => onSend(deposit!)}>
<Typography color='primary'>{'Submit'}</Typography>
</Button>
</InputAdornment>
)
}}
/> |
Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4. **This update includes a security fix.** - [Release notes](https://github.com/acornjs/acorn/releases) - [Commits](acornjs/acorn@5.7.3...5.7.4) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Hi I was wondering if there is a property to set the max length of the text-input so that when the user enters a certain amount of letters they will not be able to enter any more?
thanks a lot!
The text was updated successfully, but these errors were encountered: