Adding a Number Field to a Form

HTML 5 contains a number type attribute of input field that is a text field. This type is used to validate the textbox only if the value within the field is a numerical value. With the max and min attributes, you can provide the additional constraint to ensure that the number is within a given range. The implementation of a number field on a Web page looks like a spin box. You can set the default value by specifying the numerical value is the value attribute of input field.

Let’s do the following steps to add number field:


<!DOTYPE html>
<head>
    <title>Adding a Number Field</title>
</head>
<body>
<center>
    <h2>Example of Number Field </h2>
    <form>
        <input type=”number” name=”num” min=”0” max=”10” value=”3” />
    </form>
</center>
</body>
</html>

Save the document with the name AddingNum.html and open on browser.