Minimum and maximum limit of a number in a number type input

Asked

Viewed 10,692 times

6

Hello, I would like to know how I can put a limit, a minimum and maximum number that can be entered in the field. For example, make the number typed in the field below not less than 0 and greater than 9.

Note: only integers from 0 to 9.

<input type="number" id="nota" name="nota" class="form-control">

1 answer

5


You can use the attributes min and max if you’re using HTML5

<input type="number" min="1" max="10">

  • Bah, that’s right. I was going to say that the user can still enter any number, but at the time of the Submit he gives the warning. Thank you very much!

  • Yes, kkk for nothing @Raylansoares. If the answer helped you mark it as correct so you can help other users with the same problem.

  • 2

    @Techies min and max are attributes of Html5, it would be fair to inform its compatibility: http://caniuse.com/#search=min

  • @Highlander I was already going to search if it worked in other versions rs, thanks for the comment.

  • I was waiting for the minimum time to mark it as correct =) @Techies

  • 1

    I added the HTML5 tag to facilitate other users tbm @Highlander

  • Tranquil @Raylansoares. Good luck in your studies.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.