Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #13898

Re: Change type of <input>

From "Jukka K. Korpela" <jkorpela@cs.tut.fi>
Newsgroups comp.lang.javascript
Subject Re: Change type of <input>
Date 2012-05-13 13:55 +0300
Organization A noiseless patient Spider
Message-ID <joo3vd$a6b$1@dont-email.me> (permalink)
References <4faf80fe$0$6958$e4fe514c@news2.news.xs4all.nl>

Show all headers | View raw


2012-05-13 12:38, Tom de Neef wrote:

> I try to change the type of an<input>  element from 'text' to 'password'.
> No problem in FF an Chrome but IE8 will not allow it.

Indeed. See the comments at
http://stackoverflow.com/questions/9419780/javascript-show-hide-password
which also includes notes on an approach based on changing the 
visibility of a password field. That is, instead of changing the type of 
an <input> element, include both <input type=password> and <input 
type=text>, and just control the visibility.

Or you could dynamically create a password field, add it to the 
document, and remove the text field.

> Or is there an alternative approach?

There's always an alternative approach. But it depends on the problem 
which approach is best. You haven't said anything about the real 
problem, just described code that presumably was meant to address a 
problem. Why on &Planet; would you want to change a text input field to 
a password input field? They're equivalent except for the obscured input 
echo in a password field and some browsers' policy of treating password 
fields differently when they store and reuse user input.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Change type of <input> "Tom de Neef" <tdeneef@qolor.nl> - 2012-05-13 11:38 +0200
  Re: Change type of <input> Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2012-05-13 12:44 +0200
  Re: Change type of <input> "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-05-13 13:55 +0300
    Re: Change type of <input> "Tom de Neef" <tdeneef@qolor.nl> - 2012-05-13 14:30 +0200

csiph-web