0

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>
Goun2
  • 417
  • 1
  • 11
  • 22

2 Answers2

2

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?

Community
  • 1
  • 1
mxle
  • 461
  • 4
  • 10
1

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; }
hdotluna
  • 5,514
  • 4
  • 20
  • 31