I have a few text inputs that I call a JS function when they are on focus. Basically this function changes the value oh this field.
When I do that, on IE, the cursor is moved to the left end of my input. That does not happen in Firefox. It just stays where I put it on the first place.
<input maxlength="5" type="text" onFocus=\"changeValueOnFocus(this);\">";
function changeValueOnFocus(myInput){
myInput.value = 1234;
}
Is there a way to avoid this?
Thanks!
Instead of
onfocusrather useonfocusin, that’ll make your code to work.EDIT
I just realized, that there is no
focusinin Firefox. Hence you need something heavier.The script:
and for
inputyou’ll need anid:Now this supposed to be a cross-browser solution.