-1

I want to put always the cursor after the last character of the textfield whenever a user attempts to put the cursor in the middle of the textfield value or somewhere. In the other words the cursor should be always after the last character of the textfield value.

Scenario: When the user move the cursor using the arrow keys the cursor is automatically put after the last character.

Another scenario would be when the user move the cursor by clicking somewhere in the text field, again the cursor should be automatically put after the last character.

How can I achieve this using JQuery?

  • 2
    C'mon do some research or show at least what you tried: http://stackoverflow.com/questions/512528/set-cursor-position-in-html-textbox – Greg01re Jun 15 '16 at 14:43
  • i am not looking for the onfocus because it does not satisfy what i want – Junald Bayog Jun 15 '16 at 14:56
  • Just change the event - you have most of the code; only the event is not the right thing. I think you can do it on your own; you didn't achieved all what you did before to stop there! – Greg01re Jun 15 '16 at 17:07

1 Answers1

0

I think I know already the answer, I'll use the click() event and position the cursor to the last whenever the textfield is cliked, and keydown check if the key pressed is the arrow keys(left or right keys), if it's the arrow keys then position the cursor after the last character