Reputation: 63
<Form.Group>
<Form.Control. onChange={e => { console.log('e------',e.target.value)}}
type='number' />
</Form.Group>
I set the type on can be number, but when I click "enter"(return button) and "-",
I still can see "e" and "-" at my input box, but I only want user see number at the inputbox.
Upvotes: 2
Views: 1785
Reputation: 13933
You can use this
<Form.Control type="number" onKeyDown={ (evt) => evt.key === 'e' && evt.preventDefault() } />
As per an existing answer to a similar question on stackoverflow
Upvotes: 2
Reputation: 4398
You can try regex.
<Form.Group>
<Form.Control.
onChange={e => if(e.target.value.match("/^\d*(\.\d+)?$/")){
console.log('e------',e.target.value)
}}
/>
</Form.Group>
Upvotes: 0