Limit the input Field to take only numbers with range

后端 未结 2 1948
旧时难觅i
旧时难觅i 2021-01-28 07:13

I want to create a input field in html where can limit the users to enter a number only between the range -40 to 130. The user can also enter decimal values For example : -40.

2条回答
  •  星月不相逢
    2021-01-28 07:24

    You can use an input of type number with the attributes min max and step like this :

    I provide a JSFiddle here. When you try to submit the form, the html5 validation displays a message if the number is out of the bounds or with more than one decimals.

    JSFiddle

提交回复
热议问题