I'm trying to set my cursor to the position of the beginning when I'm on focus of a text box. This is what I have:
$("ID").focus(function () {
var input = this;
setTimeout(function() {
input.setSelectionRange(0, 0);
}, 0);
});
But I get this error every time I try to load the script:
Uncaught InvalidStateError: Failed to execute 'setSelectionRange' on 'HTMLInputElement': The input element's type ('email') does not support selection.
Guess I can't use setSelectionRange
on emails. So, any other solutions on how to set my cursor position in the input text box (without changing the type email)?
type="email"
. Thetype="number"
has the same issue... you could voice your opinion in the discussion on w3.org (it is specifically for number inputs; I haven't searched for a email type input discussion). Similar to #21177989 – Spinster