File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Stopping cursor in position Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Stopping cursor in position" Watch "Stopping cursor in position" New topic
Author

Stopping cursor in position

Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

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.


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

Are you talking about the cursor (mouse) or the caret (text entry postion)?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Nov 16, 2005
Posts: 502

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

Joined: Nov 08, 2001
Posts: 15376
    
    6
Have fun trying to figure that out! See what you can come up with.

Eric
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

Eric,

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

Below is code...



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stopping cursor in position
 
Similar Threads
To jump a position of the Cursor in the Text
tab press in JTable should go to the next rows text fieldhow?
html file with multiple form elements
Request Focus
Positioning the cursor in an input field