You must change the input element type as:
y.setAttribute('type','text'); //or y.type = 'text';
1) Any custom java script inside the body tag, as shown below:
<input type="hidden" id="txtHiddenUname" value="invalid input" /> <script type="text/javascript"> var y = document.getElementById("txtHiddenUname"); y.type= "text"; </script>
OR
2) Use some event handler like onload
<head> <script type="text/javascript"> function on_load(){ var y = document.getElementById("txtHiddenUname"); y.type= "text"; } </script> </head> <body onload = "on_load()"> <input type="hidden" id="txtHiddenUname" value="invalid input" /> ...
so that the DOM is ready.
source share