How to give a limit to the input field in HTML?

The HTML tag is used to get user input in HTML. To give a limit to the input field, use the min and max attributes, which is to specify a maximum and minimum value for an input field respectively.

The max and min attributes are used with number, range, date, datetime, datetime-local, month, time and week input types.

Example

You can try to run the following code to give a limit to the input field in HTML −


   
      HTML input number
   
   
      
         Mention any number between 1 to 10          
               
   
Updated on: 2020-06-15T11:04:46+05:30

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements