Reputation: 1747
My goal is to limit the length of an input of type number to just one number. For this I used the response of Vikasdeep Singh in this SO answer which in my case is working perfectly. I also had to remove the input inner arrows as I use an onkeypress eventlistener to limit the length of the input. My question is why as shown below when using just return it is not stopping the length of the number while it is when using return false?
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type=number] {
appearance: textfield;
}
<input type="number" onkeypress="if(this.value.length===1){return false}">
<input type="number" onkeypress="if(this.value.length===1){return}">
Upvotes: 0
Views: 19