473,508 Members | 2,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Switich Input field from TYPE=TEXT to TYPE=PASSWORD

Hi everyone,

I have a page with a login box. Because of lack of space, instead of
labels I put the descriptive text in the input fields (so username input
says 'username', and password input says 'password').

The password field however, once it does have the focus, it should mask
its input. Now what I've done, and works in firefox, is
onfocus="this.type='password'; this.value='';". (Its a bit more complex
than that, but this is essentially it). Unfortunatly IE complains.

Is there any way to perform this trick in IE without showing and hiding
components? In other words, is there a way to change the type of an
INPUT or make an INPUT TYPE="text" field mask anyway?

Thanks,
Vincent
Jul 13 '06 #1
5 8137
Vincent van Beveren wrote:
Hi everyone,

I have a page with a login box. Because of lack of space, instead of
labels I put the descriptive text in the input fields (so username input
says 'username', and password input says 'password').

The password field however, once it does have the focus, it should mask
its input. Now what I've done, and works in firefox, is
onfocus="this.type='password'; this.value='';". (Its a bit more complex
than that, but this is essentially it). Unfortunatly IE complains.

Is there any way to perform this trick in IE without showing and hiding
components? In other words, is there a way to change the type of an
INPUT or make an INPUT TYPE="text" field mask anyway?
An alternate approach is to have a separate password field and to
position your special text field over it so that when your text field
receives focus, it does this.style.display="none" and will disappear.

Csaba Gabor from New York

Jul 13 '06 #2
try

onfocus = "this.setAttribute('type', 'password')"

might work.

Jul 13 '06 #3
go*****@gmail.com said the following on 7/13/2006 10:21 AM:
try

onfocus = "this.setAttribute('type', 'password')"

might work.
And then again, it won't. It would have taken less time to test it than
post it though.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 13 '06 #4
>onfocus = "this.setAttribute('type', 'password')"
>>
might work.

And then again, it won't. It would have taken less time to test it than
post it though.
I tried that, makes no difference. I guess I'll go for the hide/show
thing, though it'll take some additional work to get the focus going
right. I also thought about dynamically replacing the whole component
with DOM. That should make the focus work more intuitively... I kinda
hoped there would be a very easy solution... If not I'll guess I'll
fiddle a bit.

Thanks!
Vincent

Jul 13 '06 #5
Vincent van Beveren said the following on 7/13/2006 3:02 PM:
>>onfocus = "this.setAttribute('type', 'password')"

might work.

And then again, it won't. It would have taken less time to test it
than post it though.

I tried that, makes no difference.
That is why I said "it won't" instead of "It might not".
I guess I'll go for the hide/show thing,
though it'll take some additional work to get the focus going
right.
focus "going right" would be simple. onfocus="that.focus()" where "that"
is a reference to the field you unhide and you onfocus the one you are
going to hide.
I also thought about dynamically replacing the whole component
with DOM.
That may or may not be the best way as it may change the tab order of
the input fields. If you try that route, set the tabIndex as well as
creating the element to retain tab navigability.
That should make the focus work more intuitively...
I kinda hoped there would be a very easy solution...
The "easiest" solution is to use a password field to start with. How
would non-JS users get a password field?

Make it a password field, onload remove it and recreate it as a text
input with the value set, then onfocus remove that input and put the
password field back. Very messy situation.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 13 '06 #6

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

Similar topics

1
3459
by: bjgriswold | last post by:
Has anyone every seen this issue where the Forms 4.5 GUI comes up but you are unable to type anything into the username or password fields? We are using NT 4 SP 6 (TSE) with Citrix 1.8. The GUI...
2
656
by: tom | last post by:
Hello, I have an asp.net web application where I want people to register themselves. This takes them through a few pages with prev/next functionality. In one of the pages they provide a...
7
30398
by: ScooterMX | last post by:
I've seen where login pages (and other form-based pages) place the cursor in the first field of a form after the page loads. I'm familiar with the tabIndex, but that only works once you hit the...
1
2946
by: dcrespo | last post by:
Hi to all, I have functions defined in an xml-rpc server. Some functions query to a Postgres database (using adodb) and return its recordset. So, if some xml-rpc client runs the mentioned...
0
1127
by: alex | last post by:
I am trying to implement "Ban user IP" functionality in my webapp by writing directly to IIS6 metabase. There is IPSecurity section that allows deny access for specific ip addresses. Here Ive found...
2
2936
by: S Moran | last post by:
many moons ago i had a small app that you could drag onto a textbox in an application or on a website that contained text that was hidden with asterisks and the underlying text would be revealed....
19
63410
kryo
by: kryo | last post by:
Hey Ya'll, I encountered another issue, with lovely internet explorer... How it likes to truly **** me off.. :X Anywho, i'm trying to do this: <form> <input type=TEXT id="some_id">
1
1824
by: gayathri33 | last post by:
I have a text field in JSF,when user enters text,text should be displayed. But onblur (i.e) wen focus moves away from the control, it should be displayed as "***" or "..." ..any one plz help asap...
5
2743
by: omar999 | last post by:
I have a CMS which displays some flight routes, alongside prices, dates which is using asp and sql server 05. works well - i.e an update on the CMS page populates the sql table and then the asp...
0
7129
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...
0
7398
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...
1
7061
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...
0
7502
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...
0
4716
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...
0
3208
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...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.