473,698 Members | 2,521 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

putting the cursor in a password field on page load

I have a page that is simply a password field. Doesn't scroll, do anything
other than accept a password, and has a submit button.

How can I automatically place the cursor in this password field when the
page loads?

I think it would be really nice to just have to type the password and hit
enter.


Jul 23 '05 #1
4 1889
"ScooterMX" <sc*****@nowher e.org> wrote in message
news:yr******** *******@newssvr 14.news.prodigy .com...
I have a page that is simply a password field. Doesn't scroll, do anything other than accept a password, and has a submit button.

How can I automatically place the cursor in this password field when the
page loads?

I think it would be really nice to just have to type the password and hit
enter.


<html>
<head>
<script type="text/javascript">

function initialize() {
document.getEle mentById(passWo rd).focus();
}

</script>
</head>

<body onLoad="initial ize();">
...
<input id="passWord" name="passWord" type="password" />
...
</body>
</html>

--
Dag.
Jul 23 '05 #2
Dag Sunde wrote:
[...]
function initialize() {
document.getEle mentById(passWo rd).focus();
}


Or if you want it to work:
function initialize() {
document.getEle mentById('passW ord').focus();
}

Note use of quotes around "passWord". If you want it to also work in
older versions of IE:

function initialize() {
if (document.getEl ementById) {
document.getEle mentById('passW ord').focus();
} else if (document.all) {
document.all['passWord'].focus();
}
}

--
Rob
Jul 23 '05 #3
function initialize() {
if (document.getEl ementById) {
document.getEle mentById('passW ord').focus();
} else if (document.all) {
document.all['passWord'].focus();
}
}


Thanks.
Jul 23 '05 #4
RobG wrote:
Dag Sunde wrote:
[...]
function initialize() {
document.getEle mentById(passWo rd).focus();
}

Or if you want it to work:
function initialize() {
document.getEle mentById('passW ord').focus();
}

Note use of quotes around "passWord". If you want it to also work in
older versions of IE:

function initialize() {
if (document.getEl ementById) {
document.getEle mentById('passW ord').focus();
} else if (document.all) {
document.all['passWord'].focus();
}
}


And if you want it to work in any browser that supports the scripting of
forms:

document.forms['formName'].elements['elementName'].focus();

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2662
by: Jim Mitchell | last post by:
I have a web page that I show using show ModalDialog. The web page takes about 6 seconds to load. No matter what I try, I can not get the cursor to show a "WAIT" until the page is loaded in the showModalDialog Window, I have even tried having a hidden panel in the calling web site and trying to turn it off from the target web site using...
5
2445
by: ChadDiesel | last post by:
My basic question is why does my print report button on my subform print a blank report when my cursor is on a blank entry line? Here is a more detailed explanation of my problem. I have a form that contains shipment destination information and a subform that contains boxes for that shipment. The main form is a table called Ship_Info, and the subform is a table called Label_Info. They both contain and are linked by a field called...
4
1733
by: Homa | last post by:
Hi, I have a quick question. I have a webpage allow user to modify his/her information. When I generate the form, I want to pre-load the information to the TextBoxes. But for the password (and confirm password) textbox, the text can't be loaded (the TextBoxes are empty, no "dot" in them). I checked inside Page_Load the text is loaded, but when the page is render, the data is flushed.
1
9775
by: Olav Tollefsen | last post by:
I use this code to set focus to a textbox when I load a page: private void SetFocus(System.Web.UI.Control ctrl) { string s = "<SCRIPT language=\"javascript\">document.getElementById('" + ctrl.ID + "').focus()</SCRIPT>"; RegisterStartupScript("focus", s); }
2
4454
by: MattB | last post by:
I have a page where a person can edit their account information and one of the things to edit is a password. I'd like to be able to pre-populate this field with something to indicate they have one already, but when I put something like this in the page load: password.text = "xxxxxx" The box still loads with nothing in it. I'd really like to have those password mask dots in there instead of nothing to indicate there is an existing...
6
2363
by: James | last post by:
Have a textbox that's in Password mode on a user creation page. Have several dropdowns that cause a PostBack out of necessity on this page. I cannot separate them. When one of these dropdowns changes, the textbox's value is lost. How do I prevent this? Thanks
7
6562
by: P. Adhia | last post by:
Sorry for quoting an old post and probably I am reading out of context so my concern is unfounded. But I would appreciate if I can get someone or Serge to confirm. Also unlike the question asked in the post below, my question involves non-partitioned table loads. I want to know if, in general, loading from cursor is slower than loading from a file? I was thinking cursor would normally be faster, because of DB2's superior buffer/prefetch...
0
1290
by: crpietschmann | last post by:
I have a databound TextBox in a FormView control with it's TextMode set to Password. My issue is that when the page loads the password field is empty. This is causing problems of clearing out the password when you hit save. Does anyone know a possible work around to make a databound TextBox inside a FormView work as desired? -- Chris Pietschmann http://pietschsoft.com
21
3857
by: tvnaidu | last post by:
This is the Java script I am using fo rlogin page, but cursor not pointing to login box, any idea how can I point cursor to login box when this page loaded?. here admin login take to control page and user login take to status page, if I give direct path without goto login, both pages display, can I add a check if user didn't login, then redirect to login page for both control.htm and status.htm, let me know. thanks in advance. <script...
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8904
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.