Server side form validation 2

This commit is contained in:
Muyao CHEN
2024-06-30 19:35:59 +02:00
parent 8394832428
commit 8be6ba7119
4 changed files with 52 additions and 3 deletions

View File

@ -8,10 +8,14 @@
<!-- <form method="post" action="" class="needs-validation" novalidate> -->
<form method="post" action="" class="" novalidate>
<input type="hidden" name="csrf_token" value="{{.CSRFToken}}">
<div class="form-group mt-5">
<label for="first_name">First name:</label>
<input type="text" name="first_name" id="first_name" class="form-control" required
autocomplete="off">
{{with .Form.Errors.Get "first_name"}}
<label class="text-danger">{{.}}</label>
{{end}}
<input type="text" name="first_name" id="first_name" class="form-control {{with .Form.Errors.Get "first_name"}} is-invalid {{end}}"
required autocomplete="off">
</div>
<div class="form-group mt-5">
<label for="last_name">Last name:</label>