View Full Version : placing the cursor at the end of a form filed.
Steven_Smith
01-09-2003, 12:46 AM
Hello!
document.formname.formfield.focus()
will place the cursor at the begining of the form field. Is there a way to place it at the end?
Steve
whammy
01-09-2003, 12:51 AM
Hmm... not that I know of, cross-browser at any rate. I think there is a way to do it in IE ONLY, but I tend to avoid proprietary client-side code on principle, therefore I never learned it.
In this type of case, I would usually either focus on the field and then select() everything, or delete the invalid entry and then focus on the field.
Someone please correct me if I'm wrong, though!
Steven_Smith
01-09-2003, 01:01 AM
In IE Only Eh?
Maybe I will just select the form field, all the user has to do is tap '->' and the cursor will go to the end.
Deleting the field would be good if its bad data, but in this case it the data is fine. I wrote an autosave feature for a large form, after 3 mins it prompts you to save (submit) your form. then it reloads the page and places the cursor in the form field that they are using. I was having problems with the form expiring.
Thanks
Steve :)
Steven_Smith
01-09-2003, 01:10 AM
Maybe there is a way to force press the users '->' key. Hmmm.. Probably not!
Borgtex
01-09-2003, 03:01 AM
That's silly, but will work on IE and NS6+
with(document.formname.formfield){focus();value=value}
Steven_Smith
01-09-2003, 04:45 PM
Thanks Borgtex, that worked perfectly!!!!
:thumbsup: :thumbsup:
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.