title: Django check if form input field is not empty
body: <p>I have a form that has a bunch of fields. These are all the fields for product checkout. So name, last name, email, adress, phone and more. Then there is a button type submit that proceeds to the next page.</p>
  
  <p>What i want to do, is if any of these fields are empty, there should be a red text saying: "field is empty" otherwise it would proceed.</p>
  
  <p>This is how i tried to do it:</p>
  
  <pre><code>&lt;form class="row contact_form" action="{% url 'create-order' %}" method="POST" novalidate="novalidate"&gt;
                    {% csrf_token %}  
                    &lt;div class="col-md-6 form-group"&gt;
                          &lt;input type="text" class="form-control" name="order-namn" placeholder="Namn"&gt;
                      &lt;/div&gt;
                      &lt;div class="col-md-6 form-group"&gt;
                          &lt;input type="text" class="form-control" name="order-efternamn" placeholder="Efternamn"&gt;
                      &lt;/div&gt;
                      &lt;div class="col-md-12 form-group"&gt;
                          &lt;input type="text" class="form-control" name="order-epost" placeholder="E-post för orderbekräftelse"&gt;
                      &lt;/div&gt;
                      &lt;div class="col-md-6 form-group"&gt;
                          &lt;input type="text" class="form-control"  name="order-adress" placeholder="Adress"&gt;
                      &lt;/div&gt;
  
  
  
  
  
                      &lt;div class="col-md-6 form-group"&gt;
                        &lt;input type="text" class="form-control"  name="order-ort" placeholder="Ort"&gt;
                    &lt;/div&gt;
  
  
                      &lt;div class="col-md-6 form-group"&gt;
                          &lt;input type="text" class="form-control" name="order-postnummer" placeholder="Postnummer"&gt;
                      &lt;/div&gt;
  
                      &lt;div class="col-md-6 form-group"&gt;
                          &lt;input type="text" class="form-control" name="order-telefon" placeholder="Telefon"&gt;
                      &lt;/div&gt;
                      &lt;div class="col-md-2 form-group"&gt;
                        &lt;select class="browser-default" name="order-land"&gt;
                            &lt;option value="Sverige" selected&gt;Sverige&lt;/option&gt;
                          &lt;/select&gt;
                    &lt;/div&gt;
                    &lt;div class="col-md-2 form-group p_star"&gt;
                        &lt;select class="browser-default" name="order-state"&gt;
                            &lt;option selected&gt;Län&lt;/option&gt;
                            &lt;option value="Blekinge län"&gt;Blekinge län&lt;/option&gt;
                            &lt;option value="Dalarnas län"&gt;Dalarnas län&lt;/option&gt;
                            &lt;option value="Gotlands län"&gt;Gotlands län&lt;/option&gt;
                            &lt;option value="Gävleborgs län"&gt;Gävleborgs län&lt;/option&gt;
                            &lt;option value="Hallands län"&gt;Hallands län&lt;/option&gt;
                            &lt;option value="Jämntlands län"&gt;Jämntlands län&lt;/option&gt;
                            &lt;option value="Jönköpings län"&gt;Jönköpings län&lt;/option&gt;
                            &lt;option value="Kalmar län"&gt;Kalmar län&lt;/option&gt;
                            &lt;option value="Kronobergs län"&gt;Kronobergs län&lt;/option&gt;
                            &lt;option value="Norrbottens län"&gt;Norrbottens län&lt;/option&gt;
                            &lt;option value="Skåne län"&gt;Skåne län&lt;/option&gt;
                            &lt;option value="Stockholms län"&gt;Stockholms län&lt;/option&gt;
                            &lt;option value="Södermanlands län"&gt;Södermanlands län&lt;/option&gt;
                            &lt;option value="Uppsala län"&gt;Uppsala län&lt;/option&gt;
                            &lt;option value="Värmlands län"&gt;Värmlands län&lt;/option&gt;
                            &lt;option value="Västerbottens län"&gt;Västerbottens län&lt;/option&gt;
                            &lt;option value="Västernorrlands län"&gt;Västernorrlands län&lt;/option&gt;
                            &lt;option value="Västermanlands län"&gt;Västermanlands län&lt;/option&gt;
                            &lt;option value="Västra Götalands län"&gt;Västra Götalands län&lt;/option&gt;
                            &lt;option value="Örebro län"&gt;Örebro län&lt;/option&gt;
                            &lt;option value="Östergötlands län"&gt;Östergötlands län&lt;/option&gt;
                          &lt;/select&gt;
                    &lt;/div&gt;
  
                      &lt;div class="col-md-12 form-group mb-0"&gt;
                          &lt;div class="creat_account"&gt;
  
  
                          &lt;/div&gt;
                          &lt;textarea class="form-control" name="message" id="message" rows="1" placeholder="Information till säljaren (Frivilligt)"&gt;&lt;/textarea&gt;
                      &lt;/div&gt;
  
  
  
  
  
  
  
              &lt;/div&gt;
              &lt;div class="col-lg-4"&gt;
                  &lt;div class="order_box"&gt;
                      &lt;h2&gt;Din Beställning&lt;/h2&gt;
                      &lt;ul class="list"&gt;
                          &lt;li&gt;&lt;a href="#"&gt;&lt;h4&gt;Produkt &lt;span&gt;Totalt&lt;/span&gt;&lt;/h4&gt;&lt;/a&gt;&lt;/li&gt;
  
  
  
                          {% for item in cartItems %}
                          &lt;li&gt;&lt;a href="#"&gt;{{ item }} x {{item.quantity}} &lt;span class="last" &gt;{{ item.get_total_item_price }} Kr&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                          {% endfor %}
  
                      &lt;/ul&gt;
                      &lt;ul class="list list_2"&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Frakt &lt;span&gt;Gratis Frakt&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Totalt &lt;span"&gt;{{shopCart.get_total}} Kr&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                      &lt;/ul&gt;
  
                      &lt;div class="payment_item active"&gt;
  
  
                      &lt;/div&gt;
                      &lt;div class="creat_account"&gt;
  
                      &lt;/div&gt;
                      &lt;div class="payment_item"&gt;
                        &lt;div class="radion_btn"&gt;
                            &lt;input type="radio" id="f-option5" name="selector" value="Klarna"&gt;
                            &lt;label for="f-option5"&gt;Klarna&lt;/label&gt;
                            &lt;img src="{% static 'assets/img/product/klarna.png' %}" alt=""&gt;
                            &lt;div class="check"&gt;&lt;/div&gt;
                        &lt;/div&gt;
                        &lt;p&gt;Klarna offers flexible payment options that allow customers more freedom to choose when and how to pay for a purchase.&lt;/p&gt;
                    &lt;/div&gt;
                    &lt;div class="payment_item active"&gt;
                        &lt;div class="radion_btn"&gt;
                            &lt;input type="radio" id="f-option6" name="selector" value="Kort"&gt;
                            &lt;label for="f-option6"&gt;Kortbetalning &lt;/label&gt;
                            &lt;img src="{% static 'assets/img/product/card.jpg' %}" alt=""&gt;
                            &lt;div class="check"&gt;&lt;/div&gt;
                        &lt;/div&gt;
                        &lt;p&gt;Betala med Kort. Alla betalningar går igenom Stripe Secure Checkout.&lt;/p&gt;
                    &lt;/div&gt;
  
                      {% if order-namn is None %}
                      &lt;div class="text-center"&gt;
                       &lt;button type="submit" class="button button-paypal"&gt;Fortsätt till Betalning&lt;/button&gt;
                      &lt;/div&gt;
                      {% endif %}
  
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
  
  
  
      &lt;/div&gt;
  
  
  
  
  &lt;/div&gt;
  </code></pre>
  
  <p></p>