JavaScript/jQuery Form - Handle the Value Change Event
To process a new form item value, you need to handle the fieldDataChanged event. If the handling function is not going to be changed during the lifetime of the UI component, assign it to the onFieldDataChanged property when you configure the UI component.
jQuery
$(function() { $("#formContainer").dxForm({ onFieldDataChanged: function (e) { var updatedField = e.dataField; var newValue = e.value; // Event handling commands go here } }); });
Angular
<dx-form ... (onFieldDataChanged)="form_fieldDataChanged($event)"> </dx-form>
import { DxFormModule } from "devextreme-angular"; // ... export class AppComponent { // ... form_fieldDataChanged (e) { let updatedField = e.dataField; let newValue = e.value; // Event handling commands go here } } @NgModule({ imports: [ // ... DxFormModule ], // ... })
Vue
<template> <DxForm @field-data-changed="formFieldDataChanged"> <!-- ... --> </DxForm> </template> <script> import 'devextreme/dist/css/dx.light.css'; import { DxForm } from 'devextreme-vue/form'; export default { components: { DxForm }, data() { return { // ... }; }, methods: { formFieldDataChanged(e) { const updatedField = e.dataField; const newValue = e.value; // Event handling commands go here } } }; </script>
React
import React from 'react'; import 'devextreme/dist/css/dx.light.css'; import { Form } from 'devextreme-react/form'; class App extends React.Component { constructor() { super(); this.formFieldDataChanged = this.formFieldDataChanged.bind(this); } render() { return ( <Form onFieldDataChanged={this.formFieldDataChanged}> {/* ... */} </Form> ); } formFieldDataChanged(e) { const updatedField = e.dataField; const newValue = e.value; // Event handling commands go here } } export default App;
jQuery
If you are going to change event handlers at runtime, or if you need to attach several handlers to the fieldDataChanged event, subscribe to this event using the on(eventName, eventHandler) method.
var fieldDataChangedHandler1 = function (e) { var updatedField = e.dataField; var newValue = e.value; // First handler of the "fieldDataChanged" event }; var fieldDataChangedHandler2 = function (e) { var updatedField = e.dataField; var newValue = e.value; // Second handler of the "fieldDataChanged" event }; $("#formContainer").dxForm("instance") .on("fieldDataChanged", fieldDataChangedHandler1) .on("fieldDataChanged", fieldDataChangedHandler2);
See Also
If you have technical questions, please create a support ticket in the DevExpress Support Center.