Forums

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

#48759
Josh
Member

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).val("");
//$(this).attr("type", "password");
//
// Lets forget jQuery for a second.
var pass = document.getElementById('formPass');
pass.type = 'password';
}
});