diff --git a/api.go b/api.go index 1e56c04..e7cc385 100644 --- a/api.go +++ b/api.go @@ -139,6 +139,12 @@ func CreatePoll(c *gin.Context) { return } + // If title length exceeds 250 characters, return a bad request + if len(c.PostForm("title")) > 250 { + c.JSON(http.StatusBadRequest, gin.H{"error": "title length exceeds limit of 250 characters"}) + return + } + quorumType := c.PostForm("quorumType") quorum, err := strconv.ParseFloat(quorumType, 64) diff --git a/templates/create.tmpl b/templates/create.tmpl index 5739f7e..d1bc7f2 100644 --- a/templates/create.tmpl +++ b/templates/create.tmpl @@ -9,7 +9,8 @@ type="text" class="form-control" name="title" - placeholder="My Poll" + placeholder="My Poll (max 250 characters)" + maxlength="250" required >