0

I want to add the newly entered key board inputs at the end of the current wordings in the textarea even the user tries to put the cursor in the middle.

gecco
  • 281
  • 4
  • 18
  • Where did you try this? – Marius Apr 05 '15 at 06:55
  • I tried it on a textarea. I tried the onfocus method. then the cursor goes to the end of the line. but still user can manually take the cursor to the middle of the sentence and enter. I want to avoid that. I have dissabled the right, left, up, down arrow keys – gecco Apr 05 '15 at 07:00
  • Btw to whom unrated the question, I did my research before adding the question. I tried my best and couldn't find anything which matches my requirements. I just cant add all the ulrs I tried here. – gecco Apr 05 '15 at 07:06

1 Answers1

2

Try this fragment of code it worked for me. jsfiddle here

  $("#InputAtLast").keyup(function(e) {
    this.selectionStart = this.selectionEnd = this.value.length;
  });
  $("#InputAtLast").focus(function(e) {
    this.selectionStart = this.selectionEnd = this.value.length;
  });
  $("#InputAtLast").click(function(e) {
    this.selectionStart = this.selectionEnd = this.value.length;
  });

For more options try this link here Click here.

Community
  • 1
  • 1
valar morghulis
  • 2,007
  • 27
  • 34