Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140161

How to block user from adding + or - in input field in react js?

$
0
0

Basically, input field should accept only 1 - 999 values

Input Field :

<input
  type="number"
  value={value}
  onChange={this.props.onViltMaxUserChange}
  min="0"
  max="999"
/>

onChange :

  onViltMaxUserChange = _.throttle(e => {
    let { value, min, max } = e.target;
    if (value !== ''&& !(_.inRange(value, min, max))) return false
    this.setState({ value: value });
  }, 50);

But User is able to add ---- or ++++ onChange is not triggered when user inputs + or -. I Don't want to allow user to input these.

How can I do this ?


Viewing all articles
Browse latest Browse all 140161

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>