Does javascript forbid changing the input type from password or to password?

I am using this code on the input element:

onmouseout="
$('#passwordhelp').text('');
$('#rpassword').attr('type', 'password')"

Upvotes: 1

Views: 307

Answers (2)

Emre Erkan
Emre Erkan

Reputation: 8482

Are you using jQuery 1.6 or above? If so try .prop(). In your case like this (Example):

onmouseout="
$('#passwordhelp').text('');
$('#rpassword').prop('type', 'password')"

Though it won't work on IE8 and below.

IMHO you shouldn't use javascript and jQuery like this. Bind your events on .ready(). But of course it's your choice...

Upvotes: 0

jk.
jk.

Reputation: 14435

You can't change the property type with jquery in the way you are attempting to do it. You're bumping into a browser issue:

See JQuery change type of input field

Upvotes: 3

Related Questions