Javascript DOM HTML Input Week readOnly Property set

Introduction

Set a week field to read-only:

document.getElementById("myWeek").readOnly = true;

Click the button to set the week field to read-only.

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">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {//from w w  w . j av a  2s.  c  om
  document.getElementById("myWeek").readOnly = true;
}
</script>

</body>
</html>

The readOnly property sets or gets whether a week field should be read-only, or not.

A read-only field cannot be modified.

This property mirrors the HTML readonly attribute.

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

Property Values

Value Description
trueThe week field is read-only
falseDefault. The week field is not read-only

The readOnly property returns true if the week field is read-only, otherwise it returns false.




PreviousNext

Related