2

This script works well in all major browsers without IE(7/8). Can you tell me how to do it with IE?

<!DOCTYPE html>
<html>
<head>
<script>
function change()
{
document.getElementById("red").type='password';
}
</script>
</head>
<body>

<form>
What color do you prefer?<br>
<input type="text" name="colors" id="red" value="Text">
</form>

<button type="button" onclick="change()">Change input type</button>

</body>
</html>
Tech Tech
  • 354
  • 1
  • 4
  • 17
Mobo
  • 118
  • 1
  • 1
  • 7

2 Answers2

2

Can you tell me how to do it with IE?

It can't be done. You need to have the two inputs, one visible and one hidden, and change their visibility, not the type.

Tech Tech
  • 354
  • 1
  • 4
  • 17
gdoron
  • 147,333
  • 58
  • 291
  • 367
1

IE (at least the old versions) doesn't support direct input type changes after the page is rendered.

As anything related to IE, there is no strait-forward solution, only hackish ones.

Aviran Cohen
  • 5,581
  • 4
  • 48
  • 75