Reputation: 97
I want to enable below button based on the boolean value from context i.e. {{ enable }}. if enable is True then make it enable otherwise disabled.
<input type="submit" name="upload" class="btn btn-primary" value="Upload" disabled/>
Upvotes: 5
Views: 9782
Reputation: 106
Try something like this to disable the button based on the condition in Django.
<input type="button" {% if a==b %} disabled="true" {% endif %}/>
Here 'a' and 'b' refers to the variables coming from the Django view.
Upvotes: 0
Reputation: 867
The simplest way to do that is:
<input type="submit" name="upload" class="btn btn-primary"
value="Upload" {% if not enable %}disabled{%endif%} />
Upvotes: 14
Reputation: 2015
do this:
{% if enable %}
<input type="submit" name="upload" class="btn btn-primary" value="Upload" />
{% else %}
<input type="submit" name="upload" class="btn btn-primary" value="Upload" disabled/>
{% endif %}
Upvotes: 3