D
D
darkglare2020-12-02 20:48:27
Django
darkglare, 2020-12-02 20:48:27

How to check condition in template form field?

Hello. There is a form field that specifies the number of items to be added to the cart. It is necessary that if the value in the field is equal to ZERO, then the ADD button will cease to be active.

<form class="flex-w flex-r-m p-b-10" action="{% url "cart:cart_add" product.id %}" method="post">
                  <div class="size-204 flex-w flex-m respon6-next"   >
                                       
                                        
                                            {% csrf_token %}
                                            {% if  user.is_authenticated %}
                    <div class="wrap-num-product flex-w m-l--100 m-r-20 m-tb-10">
                                            
                      <div class="btn-num-product-down cl8 hov-btn3 trans-04 flex-c-m">
                        <i class="fs-16 zmdi zmdi-minus"></i>
                      </div>

                      <input class="mtext-104 cl3 txt-center num-product" type="text" name="quantity" required id = "id_quantity" value="1"  >

                      <div class="btn-num-product-up cl8 hov-btn3 trans-04 flex-c-m">
                        <i class="fs-16 zmdi zmdi-plus"></i>
                      </div>
                     </div>
                                        
                                        
                                        <input class="flex-c-m stext-101 cl0 size-101 bg1 bor1 hov-btn1 p-lr-15  trans-04 js-addcart-detail" type="submit" value="В корзину" >
                                   {% else %}
                                            <p class="stext-102 cl3 p-t-23">Для добавления товара в корзину, <a href="{% url 'login' %}" > авторизуйтесь.</a> </p>
                                        {% endif %}

 </div>
</form>


That is, if in this line
<input class="mtext-104 cl3 txt-center num-product" type="text" name="quantity" required id = "id_quantity" value="1"  >
value="0" is set in the template, then the "Add to Cart" button should stop being active.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Art005, 2020-12-02
@Art005

javascript

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question