[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Text field to Password field using javascript.

Posted on 2005-05-15
3
Medium Priority
?
1,261 Views
Last Modified: 2010-05-18
Hi Experts,

I have a text field in HTML page.  Using Javascript I just want to change the text to password field and password to text field.

I am developing a software that supports this funtionality in Windows Program using some APIs. I just want to support all those in the HTML also.

PS: I can't create different instance of text field for the password... i have to set it the same field...

Please suggest.

~roshan
0
Comment
Question by:Roshan Davis
2 Comments
 
LVL 15

Accepted Solution

by:
SnowFlake earned 2000 total points
ID: 14009078
strictly speeking you can not chage the type as the type property is "write-once"
 

http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/type_7.asp

>As of Microsoft Internet Explorer 5, the type property is read/write-once, but only when an input element is created with the createElement method and before it is added to the document.


however you can overwrite the control with a new instance using outterHTML
the same method I use here to reconstruct its value can also be used to reconstruct other attributes.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
      <body>
            <INPUT id="Field1" type="password" name="Field1"><br>
            <A href="#" onclick="var v=document.all.Field1.value;document.all.Field1.outerHTML='<INPUT id=Field1 type=text name=Field1>';document.all.Field1.value=v;return false;">Change To Text</span><br>
            <A href="#" onclick="var v=document.all.Field1.value;document.all.Field1.outerHTML='<INPUT id=Field1 type=password name=Field1>';document.all.Field1.value=v;return false;">Change To Password</span><br>
            
      </body>
</html>

SnowFlake
0
 
LVL 17

Expert Comment

by:Cem Türk
ID: 15703519
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
    Accept: SnowFlake

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

cem_turk
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question