Reputation: 15
I'm trying to change the HTML5 input tag from text to date using JavaScript, the markup really changed.. but the IE Still allow user to type any characters or number. after giving up I tried to insert new element but same result!!
getting div:
<div id="myDiv">
</div>
var obj = document.getElementById("myDiv");
insert new input elemnt:
var DataType ="date";
var inputStr = "<input type='" + DataType + "' class='input-lg'/>";
obj.innerHTML = inputStr;
I tried the solution on change html input type by JS? and I got an error when changing type:
<script type="text/javascript">
document.getElementById('hybrid').type = 'password';
</script>
Any one can help?
Upvotes: 1
Views: 193
Reputation: 45750
If it shows a textbox instead of the input type you chose, that means the browser doesn't support that input type (it defaults to a text box).
Unfortunately in this case, IE doesn't yet support date input (along with Safari, Opera and Firefox), so you'll need to include a library that provides date input functionality if you want to support these browsers and need date input.
Upvotes: 3