The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [Solved] Changing Input Field Type Re: [Solved] Changing Input Field Type


I believe that jQuery does not allow you to do this for security reasons.
However I know you can do this with pure javascript.

$("#formPass").focus(function() {
$(this).css("background-color", "white");
$(this).css("color", "#333333");
var contents = $(this).val();
if(contents == "Password") {
//$(this).attr("type", "password");
// Lets forget jQuery for a second.
var pass = document.getElementById('formPass');
pass.type = 'password';