foreword
There are many scenarios in the project, you may only want to let the user input positive integers, no decimal points, no letters, punctuation, Chinese, etc.
Of course, being able to enter whole numbers and decimals is also a very common requirement, such as amounts.
solution
The following examples are all checked by regular expressions and are recommended for their simplicity.
1. Only positive integers can be entered, all other characters are invalid:
<input type="text"
onkeyup="value=value