You can use Javascript onkeydown
event here... Which will prevent the user to type anything, and still he will be able to use the arrow controls to increase and decrease the numbers.
<input type="number" min="0" value="0" step="5" onkeydown="return false" />
Demo
Note: Just don't depend on JavaScript and HTML, always have a server side validation to ensure that user didn't posted any malicious input. Javascript can be disabled and user can misuse by adding any text in the textbox, but there is no other way you can stop him, so keep a server side check as well.
As you commented that you will like to disable the text selection as well, so that users don't get confused, you can also use CSS positioning techniques here, as you said that intended users are of Chrome only, so there is not much of cross browser issue, so you can do something like this...
Demo 2
Wrap the input
element with the span
element, and just with CSS positioning technique and :after
pseudo, we overlay a virtual element over the input
.
Now I've kept the outline just for the demonstration purposes, you can remove them safely.
span {
position: relative;
outline: 1px solid #00f;
}
span:after {
content: "";
width: 100%;
height: 100%;
left: 0;
top: 0;
position: absolute;
outline: 1px solid red;
width: 91%;
}