Skip to content

Commit 2d1122f

Browse files
committed
style: Change border color for fields with validation errors
1 parent cd11835 commit 2d1122f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

djangosnippets/templates/account/login.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ <h3>Sign In</h3>
2222
<label class="text-base text-left">{{ field.label }}</label>
2323
<span aria-hidden="true" class="text-4xl text-red-400 h-2 ml-1">*</span>
2424
</div>
25+
{% if field.errors %}
26+
{{ field|add_class:"h-12 text-lg rounded-lg border-red-600 border-2 my-2" }}
27+
{% else %}
2528
{{ field|add_class:"h-12 text-lg rounded-lg border-base-green-400 border-2 my-2" }}
29+
{% endif %}
2630
{% if field.help_text %}<div class="w-full text-left ml-4 font-text">{{ field.help_text|safe }}</div>{% endif %}
2731
{% if field.errors %}<ul class="m-0 w-full ml-4 text-left text-red-600 font-text">{% for error in field.errors %}<li>{{ error }}</li>{% endfor %}</ul>{% endif %}
2832
</div>

djangosnippets/templates/account/signup.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ <h3>Sign Up</h3>
2424
<label class="text-base text-left">{{ field.label }}</label>
2525
<span aria-hidden="true" class="text-4xl text-red-400 h-2 ml-1">*</span>
2626
</div>
27+
{% if field.errors %}
28+
{{ field|add_class:"h-12 text-lg rounded-lg border-red-600 border-2 my-2" }}
29+
{% else %}
2730
{{ field|add_class:"h-12 text-lg rounded-lg border-base-green-400 border-2 my-2" }}
31+
{% endif %}
2832
{% if field.help_text %}<div class="w-full text-left ml-4 font-text">{{ field.help_text|safe }}</div>{% endif %}
2933
{% if field.errors %}<ul class="m-0 w-full ml-4 text-left text-red-600 font-text">{% for error in field.errors %}<li>{{ error }}</li>{% endfor %}</ul>{% endif %}
3034
</div>

0 commit comments

Comments
 (0)