Skip to content

Commit 008cd46

Browse files
maxlength prop added.
1 parent b7f96c2 commit 008cd46

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ this.refs.input.clear();
242242
| leftButtons | none | object(component) | left buttons component |
243243
| rightButtons | none | object(component) | right buttons component |
244244
| inputRef | none | function | input or textarea ref |
245+
| maxlength | none | int | input or textarea maxlength |
245246

246247

247248
## Button Component

src/Input/Input.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export class Input extends Component {
1313
}
1414

1515
onChange(e) {
16+
if (this.props.maxlength && (e.target.value || '').length > this.props.maxlength)
17+
return;
18+
1619
this.setState({
1720
value: e.target.value
1821
});
@@ -123,6 +126,7 @@ Input.defaultProps = {
123126
autoHeight: true,
124127
inputStyle: null,
125128
inputRef: null,
129+
maxlength: null,
126130
};
127131

128132
export default Input;

0 commit comments

Comments
 (0)