Show / hide error messages for a field.
Please note - this property requires the Editor extension for DataTables.
The full Editor reference documentation is available to registered users of Editor - the information shown below is a summary only. If you already have an Editor license please sign-in, alternatively an Editor license can be purchased on this site, or sign up for the free trial.
If invalid data is entered into a field, you will likely want to show an error message for that field telling the user what the error is and how they can correct it - client-side validation is a typical example of where this might be useful.
This method provides that ability, giving a way to set or remove an error message for a field.
Note that when submitting data to the server, the process on the server will also have to perform its own validation, and can report field errors to the client-side. When it does so, this method is used to display the error message that the server returns for the field.
Note that the
error() method also provides the ability to show and hide an error message for a specific field, and also extends that ability to being able to set a form level error message. For field errors, these two methods can often be used interchangeably. The key difference is in the return value - this method will return a
DataTables.Editor.Field instance, while the
error() method returns a
DataTables.Editor instance. This can effect how you chain methods if you are using the returned value for chaining.