add form validation

This commit is contained in:
Philipp 2021-08-29 18:22:08 +02:00
parent 82f11b254b
commit 3f2cbcea33
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 276B613AF9DBE9C3
8 changed files with 131 additions and 18 deletions

View file

@ -9,12 +9,19 @@
{{.CSRF}}
<div class="form-group">
<label>Title</label>
<input name="title" type="text" class="form-control" placeholder="Give your post a great title">
<input name="title" type="text" class="form-control {{with .Form.Errors.Title}}is-invalid{{end}}" placeholder="Give your post a great title" value="{{with .Form.Title}}{{.}}{{end}}">
{{with .Form.Errors.Title}}
<div class="invalid-feedack">{{.}}</div>
{{end}}
</div>
<div class="form-group">
<label>Text</label>
<textarea name="content" class="form-control" rows="3"
placeholder="Tell people about your thoughts"></textarea>
<textarea name="content" class="form-control {{with .Form.Errors.Content}}is-invalid{{end}}" rows="3" placeholder="Tell people about your thoughts">
{{- with .Form.Content}}{{.}}{{end -}}
</textarea>
{{with .Form.Errors.Content}}
<div class="invalid-feedack">{{.}}</div>
{{end}}
</div>
<button type="submit" class="btn btn-primary">Submit Post</button>
</form>