Javascript DOM HTML Input Week defaultValue Property set

Introduction

Change the default value of a week field:

document.getElementById("myWeek").defaultValue = "2014-W43";

Click the button to change the default value of the week field.

input elements with type="week" are not supported in Internet Explorer or Firefox.

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="week" id="myWeek" value="1995-W35">
<button type="button" onclick="myFunction()">Test</button>
<script>
function myFunction() {//from   w ww  .  j  a  v a2s  .  c om
  document.getElementById("myWeek").defaultValue = "2014-W43";
}
</script>

</body>
</html>

The defaultValue property sets or gets the default value of a week field.

The default value is the value specified in the HTML value attribute.

The defaultValue contains the default value, while value contains the current value after some changes have been made. If there are no changes, defaultValue and value is the same.

The <input type="week"> element is not supported in Firefox.

The defaultValue property accepts and returns a String type value.




PreviousNext

Related