-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client side validation #106
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just had a play around with this in order to get client side validation working for my use case. Not sure if there is interest in a PR. But in short, I modified django_quill.js to also check the length of the text input (via their getText() method) on input change. And then compared that to minlength, maxlength and required attrs from the django formfield. Depending on the check, I'm just adding a class attribute to the parent div of the quill editor, e.g. 'ql-invalid' and then using tailwinds group inheritance to show a red border/ help text to the user.
Some sample code below.
As a side note -- the actual length of the field data going to the db will be much greater than that on the client side check. Since it includes the content of both the delta and html dict keys. So, I'm using this to help enforce some control on the client side, but the max_length parameter doesn't match that of the model field.
The text was updated successfully, but these errors were encountered: