Client-side Validation in Editor
Client-side Validation in Editor
ayz
Posts: 63Questions: 23Answers: 1
Notwithstanding the need to validate on the server, there are times you want to save the round-trip.
From my understanding of the documentation, Editor has no config options to validate fields. Thus one should seek to manually validate in an event like preSubmit.
Is this understanding correct?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
That is absolutely correct. This is a shortcoming that I plan to address in future (perhaps 1.8), but I wanted to try and ensure that developers using Editor did their validation on the server-side first and foremost.
Allan
Would there be any advantage having it native to DataTables? One could as well use something like http://formvalidation.io right?
No - when I get to this I do want to be able to hook into existing validation libraries. I did investigate this a while back and found it difficult since most assume that they should hook into the fields themselves, whereas I really just want the validation functions and to call them from Editor. There is a good chance things have changed a bit now - certainly the plan is to try and make use of existing libraries rather than starting afresh there.
Allan
I know exactly what you mean!
If it can be useful to anyone.
For the moment I use HTML built-in attributes and form validation and then field.error to show the message...
Approximately like that:
Then in editor
presubmit
:A dictionary and translation library can also be used to format the error message using the validity's properties.
ex:
Looking forward for a built-in client-side form validation lib...
@jybleau: looks good, thanks!