onChange( )
Adds an event handler that runs when an input element's value is changed.
Description
A mobile element receives a change
event when a mobile app user changes the value
in an input element.
A change
event is not triggered when you change an element's value using
the element's value
property.
Because onChange()
is fired before validations are performed, do not check
any of the validation properties in the onChange()
event handler. For example,
do not code an if
statement that checks the valid
property in the onChange()
event handler,
because the property at this point contains values prior to validation.
Syntax
function onChange(handler: EventHandler): MobileElementhandler: function EventHandler(event: Event): void
onChange Parameters
NAME
TYPE
DESCRIPTION
The name of the function or the function expression to run when the element's value changes.
EventHandler Parameters
NAME
TYPE
DESCRIPTION
Returns
This function does not return anything.
Return Type:
Was this helpful?
Get the value of the element that was changed
1$w("#myMobileElement").onChange( (event) => {2 let newValue = event.target.value; // "new value"3});