{hero}

errorMsg()

Since: DateTime 1.0.0

Either sets the error message or removes it.
Please note - this property requires the DateTime extension for DataTables.

Description

Either sets the error message or removes it depending on if the msg parameter is passed or not.

This is useful for providing custom error messages when an error occurs.

Types

errorMsg()

Empties the error message.

Returns:

DateTimeSelf for chaining.

errorMsg(msg)

Sets the error message.

Parameters:

Returns:

DateTimeSelf for chaining.

Examples

Set Error Message:

var dt = new DateTime(document.getElementById('example'));

dt.errMsg('Oops an error occurred!');

Basic validation - set and clear an error message:

var dt = new DateTime(document.getElementById('example'));

el.addEventListener('change', function () {
	if (dt.val()) {
		// There is a value - clear the error message
		dt.errMsg();
	}
	else {
		// No value - error
		dt.errMsg('oops an error occurred!');
	}
});