lundi 15 mars 2021

How to prevent user from entering negative number in react?

I want to restrict users from entering negative values. I am using min = "0". With this i can restrict users from decrementing to 0, i.e, users can only decrement value till 0. But they are able to type "-". How to prevent in react js.

                      <input
                        type="number"
                        min="0"
                        step="1"                        
                        onChange={this.handleChange}                        
                        className="w-100"
                        
                        value= "1
                      />



Aucun commentaire:

Enregistrer un commentaire