value
Sets or gets a text input's value. This value will always be of type string, regardless of the text input's inputType
.
Description
To reset the text input, restoring any placeholder text, set the value
property to null
or undefined
.
Changing a text input's value
property to null
or undefined
will set the element's valid
property to false
and cause the element to visually indicate that it's contents are invalid. For example, a black outline might change to a red outline.
You can remove this visual indication until the next time the element is updated by calling resetValidityIndication()
.
Notes:
Changing a text input's
value
in code does not trigger anonChange
event.Using the Input Settings panel in the Editor you can set the type of a text input. That type is used only for validation purposes. The value returned by the
value
property of a text input is always a string, regardless of the type set in the Editor.If an element is connected to a dataset, setting the element's
value
in code does not set the value of the connected field in the dataset. That means if you use the dataset to perform a submit, the value changed in code is not reflected in the submitted item.To submit the new value using a dataset, set the field's value using the
setFieldValue()
function before performing the submit.
Type:
Was this helpful?
1let myValue = $w("#myElement").value; // "42"
1$w("#myElement").value = "42";
1$w("#myElement").value = undefined;2$w("#myElement").resetValidityIndication();