Reputation: 117
I need to allow only to enter numeric values in my Form.Control with react-bootstrap. Also, I need to give a maximum length to the control.
I have tried using type="number" and maxLength="10", but it allows me to enter more than 10 digit and there is a default style that applies to the control with two arrows to increase and decrease the number, which I don't want.
<Form>
<Form.Group>
<Form.Control
className="mobileBox"
required
name="mobile"
type="number"
maxLength="10"
value={props.mobile}
onChange={props.onChange}
/>
</Form.Group>
</Form>
Upvotes: 4
Views: 12908
Reputation: 3666
you can remove the spin boxes for number increase and decrease by adding this CSS style
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
margin: 0;
}
Upvotes: 4