Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stopping cursor in position

 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anyway to stop the cursor in a place where it even somebody types in something?

My Requirement is,

The cursor should focus to the next text field and stop at the beginning of the next enabled text field if this current field is reaches its maxLength.

Note that, it should stop even user types in something.

Thanks in advance.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you talking about the cursor (mouse) or the caret (text entry postion)?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got to love requirements wrotten by people that do not understand web programming....

You have the maxlength=4 which will not allow anything over that length. You would add that to your element

You can use onkeypress events on the element to check the length and focus() onto the next element

if(this.length==this.maxlength)document.forms[0].nextElementName.focus();

Eric
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,

I'm talking about Caret.

Eric,

It will focus to next field. Suppose

1. if I have some value in the next field then caret should be in starting of the field.

2. if next field has its value by default and It reached the maxLength, cursor should stay in the starting of the field and it should not move even if user types in something.(Now it is moving to the end of the field)

Thanks for your replies.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have fun trying to figure that out! See what you can come up with.

Eric
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,

I found out the solution for this issue. This will work only in IE.

Below is code...



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic