Adding custom message that is updated as user fills out a form
Adding custom message that is updated as user fills out a form
My data include admission date and discharge date allowing the calculation of LOS.
The LOS should be the max allowed for data entry of a third field. As the user enters admission and discharge date, I would like to update (without going back to the server) the message for the third field "Please enter a number between 1 and LOS."
It seems that this can be accomplished using the API method fields().message, but I am unable to get this to work. I tried to define the message as a function as in:
message: function(data,type,row){var test=data().pluck('ddate'); return test;}
but that just shows the text of the function as the message.
I also don't understand from the documentation how to get text editor to listen to an edit event on the admission and discharge date fields. I usually can work well from examples, but there are no examples that show the syntax for generating custom dynamic field messages, all I have found is at https://editor.datatables.net/reference/option/fields.message.
Thank you for kind feedback.
This question has an accepted answers - jump to answer
Answers
Sounds like a good use case for the
dependent()
method:I'm not sure what the calculation is, or what the fields names are, but that will run every time
ddate
has its value changed and set a message for the given field.Allan
Perfect, your sent exactly what I needed! I got it to work, thank you!!!