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.
Asked
Active
Viewed 44 times
0
-
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 Answers
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
-
there are many ways to accomplish this go for any one of 'em. I think it might be a help. – valar morghulis Apr 05 '15 at 07:08
-
let square the negative score for you, for future reference, try to add code snippet or jsfiddle. Guys are getting a bit strict on this portals now a days. – valar morghulis Apr 05 '15 at 07:17