Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

form data validation #106

Closed
yoanmalie opened this issue Apr 24, 2021 · 3 comments
Closed

form data validation #106

yoanmalie opened this issue Apr 24, 2021 · 3 comments
Assignees
Labels
☑️ done Ready for beta, but not released yet
Milestone

Comments

@yoanmalie
Copy link

Hello,
I did not find a way to check the data sent from the comment form before it's registered, like if all fields are filled, if the email adress is a valid format, etc. And show an error message if not.

I saw that i'ts throw an error exception if a field is empty, but what I want is just show the error to the users and keep the form + the data already filled.

Is there a way to do that? Thanks !

@sebastiangreger
Copy link
Owner

Hi,

Quite a few of these should actually be caught by the form's HTML validation (e.g. the type="email" input field instructs the browser to check validity and output an error message instead of submitting, if needed). For required fields, the required attribute in the form should similarly trigger an error in the browser instead of submitting an empty field.

But this indeed does not catch everything and backend validation would be neat to have. Anecdotally (mostly documenting this as a note-to-self here), there is even some built-in validation stub for the text field present in the code (here), but it is not currently returned to the frontend (because here).

Thank you for your feedback, we should definitely keep this in mind for future development! In the meantime, your best bet would be to implement the desired UI feedback by extending the browser's native error handling based on the form's HTML markup, e.g. https://www.quirksmode.org/blog/archives/2017/12/native_form_val.html and https://www.upyoura11y.com/handling-form-errors/ have some good pointers.

@sebastiangreger sebastiangreger added the enhancement New feature or request label Apr 27, 2021
@sebastiangreger sebastiangreger added ☑️ done Ready for beta, but not released yet and removed enhancement New feature or request labels Apr 29, 2021
@sebastiangreger sebastiangreger self-assigned this Apr 29, 2021
@sebastiangreger sebastiangreger added this to the 2.0 milestone Apr 29, 2021
@sebastiangreger
Copy link
Owner

The first beta of Commentions v2.0 moves the form validation from frontend to backend, adding more useful user feedback and various customisation options.

Still ironing out a few details, but if you are interested feel free to try it; feedback is of course most welcome 🙂

@sebastiangreger
Copy link
Owner

@yoanmalie I hope you don't mind me pinging you here in a slightly off-topic manner, but I'd like to draw your attention to my update that I am no longer able to maintain the Commentions plugin in the future → details here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
☑️ done Ready for beta, but not released yet
Projects
None yet
Development

No branches or pull requests

2 participants