Skip to content

Commit 3e9095f

Browse files
nikhilgupta30apollonian
authored andcommitted
Limit length of numInput
1 parent 1c305e6 commit 3e9095f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/demo/index.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ class Demo extends Component {
2121
};
2222

2323
handleChange = e => {
24-
this.setState({ [e.target.name]: e.target.value });
24+
let currVal = e.target.value;
25+
if(currVal<0) currVal = 0;
26+
if(currVal>10) currVal = 10;
27+
this.setState({ [e.target.name]: currVal });
2528
};
2629

2730
clearOtp = () => {
@@ -59,6 +62,7 @@ class Demo extends Component {
5962
value={numInputs}
6063
onChange={this.handleChange}
6164
min="0"
65+
max="10"
6266
/>
6367
</label>
6468
</div>

0 commit comments

Comments
 (0)