Don't allow posting an empty comment
This commit is contained in:
parent
662d04ce3d
commit
0410065d5d
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue
Block a user