I have tried to restrict users in HTML text box to insert only 4 digit numbers 0-9.
I have tried as follows but it restrict only to allow two digit numbers.
<input type="text" name="pincode" maxlength="4" id="pin" pattern="^0[1-9]|[1-9]d$" required/>
See Question&Answers more detail:os