Issue with inError()
Issue with inError()
There appears to be an issue with inError() not correctly reflecting the error state in preSubmit.
Using the test case below, the console output should be false, false, ''
on the first submit, then true, true, 'Dummy Error'
on the second submit.
https://live.datatables.net/judugaza/1/edit?js,console,output
This question has an accepted answers - jump to answer
Answers
Actually this is intentional. It might seem slightly counter intuitive at first, but what is happening is that when the form is submitted, we assume know knowledge of the validity of the form's content. It is up to
preSubmit
(or others) to determine if the contents are currently valid.This is a comment in the
submit
API method's code:The same applies to the fields.
If that wasn't automatically done in Editor, then you as a developer would be required to clear out any errors that might have been set already, and they could have come from a number of places. We could make a method to allow them to be cleared out, but I took the decision to automatically clear them, under the assumption that the form would be validated on each submit (which it should be anyway).
Allan
Thanks for the explanation Allan, this behaviour must have have changed after 1.7 since I've just upgraded. Not an issue, but would you be able to update the documentaion in inError() to reflect this?
As an aside I also noted that in the source you have
$(this.dom.formError);
which appears to be superfluous.Thanks - I spotted that as well while looking into this. I've committed a change to the
inError()
docs and that will update on the site soon.Allan