简体   繁体   中英

react-bootstrap-typeahead restrict input to only numbers

Using the react-bootstrap-typeahead

<Typeahead
    {...this.state}
    id="basic-example"
    onChange={id => this.setState({ id })}
    options={id}
    placeholder="Select ID"
/>

is to possible to restrict the input of Typeahead to only numbers? if yes, provide an overview how to do it

Yes you can set the inputProps :

<Typeahead
  {...this.state}
  id="basic-example"
  inputProps={{
    type: 'number',
  }}
  onChange={id => this.setState({ id })}
  options={id}
  placeholder="Select ID"
/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM