I added the code below to select whole text when user click on input box:
<input type="number" onclick="this.setSelectionRange(0, this.value.length)" name="quantity" />
But I receive the error below:
Uncaught InvalidStateError: Failed to execute 'setSelectionRange' on 'HTMLInputElement': The input element's type ('number') does not support selection.
Use input type="tel"
instead.
For your example:
<input type="tel" onclick="this.setSelectionRange(0, this.value.length)" name="quantity" />
That will do the trick and avoid the error message.
And on mobile phones, it shows up the desired number pad.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With