How to make the HTML input tag only accept numerical values?

Spread the love

Sometimes, we want to make the HTML input tag only accept numerical values.

In this article, we’ll look at how to make the HTML input tag only accept numerical values.

How to make the HTML input tag only accept numerical values?

To make the HTML input tag only accept numerical values, we set the type attribute.

For instance, we write

<input type="number" name="someid" />

to set the type attribute to number to make the input a number input.

Conclusion

To make the HTML input tag only accept numerical values, we set the type attribute.

Leave a Reply

Your email address will not be published. Required fields are marked *