2

I've found the following problem. Imagine that we have input[type="text"] element without value and with some placehplder text. When input's type is dynamically changed from "text" to "hidden" input's value becomes equals placeholder text. The issue doesn't occur for "static" hidden inputs.

The following code and a demo demonstrate the problem:

<input type="text" name="oprDate" placeholder="Date" class="form-control field-oprDate-control" value="">
<button id="btn" type="button">Run</button>
<div>
  Input's value is is: 
  <span id="res"></span>
</div>

var btn = document.getElementById("btn"),
    input = document.getElementsByName("oprDate")[0],
    res = document.getElementById("res");

btn.addEventListener("click", function(evt) {
    input.type = "hidden";
    res.innerHTML = input.value;
});

I suppose that such behavior is incorrect even if placeholder attribute is useless for hidden inputs. What do you think?

Dmitriy
  • 683
  • 2
  • 13
  • 26

0 Answers0