0

I found a possible solution to my question, however, since I'm new to javascript I can't seem to get the desired behaviour.

The solution is posted by mcpDESIGNS here

Set keyboard caret position in html textbox

What I wish to have is force the caret position back to 0 as soon as the field is focused I have created a fiddle which will help demonstrate what I'm doing.

fiddle: http://jsfiddle.net/KuLTU/

addLoadEvent(function() {
document.getElementById("search_string").onfocus = search_field_focus;
});

function search_field_focus() {
    setCaretPosition("search_string", 0);
}

I assume the why I'm calling setCaretPosition is wrong, any suggestion?

Community
  • 1
  • 1
elad.chen
  • 2,375
  • 5
  • 25
  • 37
  • The solution over there wasn't working for me as well.. – elad.chen Jul 18 '13 at 20:42
  • You have to be a little more specific than that, since it seems to work for plenty of other people. What isn't working? And are you getting and errors/exceptions in your log? – GJK Jul 18 '13 at 20:45
  • Also, either way, this is a duplicate. You should be asking your questions in that thread, not this one. – GJK Jul 18 '13 at 20:46
  • This doesn't work for me. When I click the actual textbox I have I expect the caret position to be in the beginning. Check out my fiddle http://jsfiddle.net/khx2w/ – elad.chen Jul 18 '13 at 20:54
  • The question has been revised, please assist. – elad.chen Jul 19 '13 at 12:05

0 Answers0