onChange
Function that is called whenever the value selected for DateTime changes.
Please note - this property requires the DateTime extension for DataTables.
Description
This option allows users to define custom functionality that should occur whenever a change to the selection within a DateTime instance occurs.
Note that you can also use the change
event that your browser will trigger on the input
element to determine when the value has been changed.
Type
function onChange(value, date, input)
- Description:
This function is called whenever the value selected for DateTime changes. It allows for custom functionality to be defined.
The callback function is executed in the scope of the DateTime instance - i.e.
this
is the DateTime instance and has access to all of its API methods.- Parameters:
Name Type Optional 1 value
No The current value that has been selected as a string.
2 date
No The current value that has been selected as a Date.
3 input
No The DateTime input element.
Default
- Value:
function
The default value for this option is a function, but it is empty and does nothing.
Example
Alert the user that they have made a change:
new DateTime(document.getElementById('test'), {
onChange: function (value, date, input) {
alert('Your new value is ' + value);
}
});