Events

All important actions trigger events. It is easy to listen to any form event either by providing on"EventName" function or by using on() and off() methods. Open up a console and see the event flow of the form below.
First Name:
Last Name:
DOB:
Category:
Text Area:
$(function () { $('#form').w2form({ name : 'form', header : 'Form Events', url : 'server/post', fields : [ { name: 'first_name', type: 'text', required: true }, { name: 'last_name', type: 'text', required: true }, { name: 'dob', type: 'date' }, { name: 'category', type: 'enum', options: { items: ['Category 1', 'Category 2', 'Category 3', 'Category 4', 'Category 5', 'Category 6', 'Category 7', 'Category 8', 'Category 9', 'Category 10']} }, { name: 'comments', type: 'text'} ], actions: { reset: function () { this.clear(); }, save: function () { this.save(); } } }); // attach event listener for all events w2ui.form.on('*', function (event) { console.log('Event: '+ event.type, 'Target: '+ event.target, event); }); });