Skip to content

Support minlength & required HTML validations #105

@thesecretmaster

Description

@thesecretmaster

Is your feature request related to a problem? Please describe.
I use HTML5 based validations whenever possible, because my site needs to support noscript users, but I like to improve the experience for users who do enable javascript. As part of that, I added easymde to the project for use in all of our markdown text editors. This was mostly great until I realized that my client side validations suddenly stopped working for my javascript enabled users, resulting in lost work when they attempted to submit work that didn't pass validations (since easymde ignores HTML5 validations), so it was sent to the server then rejected (and they were redirected back to the editor page, which no longer contained their content).

Describe the solution you'd like
There are two possible solutions to this problem: 1) easymde can check for the html attributes minlength and required when an editor is created, then show a warning when focus leaves the editor or 2) easymde can find it's parent form and add a submit listener, which will stop the form from submitting and show an error message if the validations don't pass.

Describe alternatives you've considered
I considered moving back to straight textareas, but I'd like to avoid that if possible. The only other alternative I can think of is writing a wrapper myself that listens to form submits, finds all the easymde children of the form, gets their values, and runs the validations. However, I'm not sure how simple this would be with codemirror.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions