I'm building my own form to git rid of help text, As I can't change the builtin form in django to remove the help text.
So far so good, but I can't style the error messages.
It's showing basic ul and il style.
How can I do it ? Thanks.
<form class="" method="post">
{% csrf_token %}
<label for="id_new_password1"> Senha </label><br>
<div class="">
<input required text="password" class="form-control" placeholder="Senha" name="new_password1"/>
{{ form.new_password1.errors }}
</div><br>
<label for="id_new_password2"> Confirmar senha </label><br>
<div class="">
<input required text="password" class="form-control" placeholder="Confirmar senha" name="new_password2"/>
{{ form.new_password2.errors }}
</div><br>
<input type="submit" class="btn btn-primary col-sm-12" value="Confirmar" />
</form>
You can use alerts . Like this:
{% if form.new_password1.errors %}
<div class="alert alert-danger" role="alert">{{ form.new_password1.errors }}</div>
{% endif %}
Also, have you tried this answer trying to get rid of the help_text?
Try to wrap up error messages in one element.
<div class="error-messages">{{ form.new_password1.errors }}</div>
.error-messages {
color: red;
font-size: 12px; }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.