ebs.addFormChangeEvent
Adds an event that triggers if the value of an attribute has changed.
Syntax
Copy
function ebs.addFormChangeEvent(formId: string, attributeName: string, eventHandler: Function): void;
| Parameter | Type | Description |
|---|---|---|
formId
|
string | The ID of the HTML element storing the form. |
attributeName
|
string | Name of the attribute you wish to monitor for changes. |
eventHandler
|
Function | Function to be triggered if the value of the specified attribute changes. Starting with release 24.2, this function accepts a single optional input parameter that conforms to the IChangeHandlerParam interface.Copy |
Examples
In this example:
- On a registration form stored in the ebsContainerContent HTML element, there is a field for an attribute called name.
- When the value of the attribute changes, we display the alert message Name changed!.
- For details on how to display alert messages, see ebs.alert.
Copy
ebs.addFormChangeEvent("ebsContainerContent","name", function(){ebs.alert("Name Changed!")});
In this example:
- On a form stored in the ebsContainerContent HTML element, there is a field for an attribute called myAttr.
- When the value of the attribute changes, we use the myChangeHandler function to log the attribute's previous and current value to the browser console.
Copy
var myChangeHandler = function(e){
console.log('Attribute value changed from ' + e.previousValue + ' to ' + e.value);
};
ebs.addFormChangeEvent('ebsContainerContent', 'myAttr' myChangeHandler);