$w.ReadOnlyMixin

$w.ReadOnlyMixin

Provides functionality for input elements which support readonly mode.

Contents

readOnly Sets or gets if a user can modify the value of the input element.
readOnly

readOnly

Sets or gets if a user can modify the value of the input element.

Syntax

let isElementReadOnly = $w("#myFormElement").readOnly;
$w("#myFormElement").readOnly = isElementReadOnly;

Description

Setting the value of the readOnly property to true prevents users from changing the element's value. However, it does not limit your ability to change the value programmatically. Setting it to false allows users to change the element's value.

Getting the value of the readonly property returns whether a user can modify the value of the input element.

You can also set an element's readonly property in the Editor using the Settings pane: Input Settings pane

Type

Boolean

Examples

Get whether the element is readOnly

bGV0IGlzUmVhZG9ubHkgPSAkdygiI215RWxlbWVudCIpLnJlYWRPbmx5OyAvLyB0cnVlCg==
let isReadonly = $w("#myElement").readOnly; // true

Set an element to be readOnly

JHcoIiNteUVsZW1lbnQiKS5yZWFkT25seSA9IHRydWU7Cg==
$w("#myElement").readOnly = true;