Don't allow posting an empty comment

This commit is contained in:
Noah 2022-08-26 20:07:55 -07:00
parent 662d04ce3d
commit 0410065d5d
2 changed files with 9 additions and 1 deletions

View File

@ -131,6 +131,13 @@ func PostComment() http.HandlerFunc {
if r.Method == http.MethodPost {
// Default intent is preview unless told to submit.
if intent == "submit" {
// A message is required.
if message == "" {
session.FlashError(w, r, "A message is required for your comment.")
templates.Redirect(w, fromURL)
return
}
// Are we modifying an existing comment?
if comment != nil {
comment.Message = message

View File

@ -161,7 +161,8 @@
<label for="message">Add your comment</label>
<textarea class="textarea" cols="80" rows="4"
name="message" id="message"
placeholder="Add your comment"></textarea>
placeholder="Add your comment"
required></textarea>
<p class="help">
Markdown formatting supported.
</p>