Menu

Every JavaScript Markdown Editor Breaks Your Form. Here's One That Doesn't
📰

Every JavaScript Markdown Editor Breaks Your Form. Here's One That Doesn't

DEV Community: html·Mohammed Rashad·about 7 hours ago
#SuxhJb03
#devto2#devto#dev#editor#fullscreen
Reading 0:00
15s threshold

You add a markdown editor to a form. It looks great. Then someone reports that the submit button does nothing, and you spend an afternoon finding out why.

Here's the form before the editor:

<form method= "post" > <textarea id= "content" name= "content" required ></textarea> <button> Publish </button> </form>

Enter fullscreen mode

Exit fullscreen mode

That required works. The browser blocks submission on an empty field and shows its own message.

Now add almost any markdown editor. The library hides your textarea, builds a contenteditable div next to it, and edits that instead. Your textarea is still in the DOM, still required , and still empty, because nobody has typed into it. The browser refuses to submit a form containing an invalid field it cannot show you, and you get no error, no focus ring, nothing.

What else breaks

The empty textarea is the obvious symptom. The rest surface later.

FormData reads nothing.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.