Search code examples
htmlinputnumbers

Is there any way to prevent input type="number" getting negative values?


I want to get only positive values, is there any way to prevent it using only html
Please don't suggest validation method

Screenshot of input control


Solution

  • Use the min attribute like this:

    <input type="number" min="0">