React Native textInput max length

React Native

React Native Problem Overview


How do you set such attribute? For example the CCV field of credit card should have a max length of 3. Expiry date should have a max length of 2 for month and 4 for years.

React Native Solutions


Solution 1 - React Native

The maxLength prop is now part of React Native:

<TextInput value={this.state.text} maxLength={4} />

Solution 2 - React Native

<TextInput value={this.state.text} maxLength={1000} />

ot is working for me to set the input text length.

Solution 3 - React Native

Please make sure you are using maxLength with camel case and not maxlengh

it seems obvious but it wasn't to me when i was breaking my head trying to figure it out hope this helps

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpuppymasterView Question on Stackoverflow
Solution 1 - React NativeDan LeveilleView Answer on Stackoverflow
Solution 2 - React NativeMenon HasanView Answer on Stackoverflow
Solution 3 - React NativeprogView Answer on Stackoverflow