Javascript hack to make it more clear that postcode is mandatory
On the two pages that display the profile form, add some javascript to flag the postcode as required whenever the Country is AU
This commit is contained in:
parent
38a99f7ae5
commit
348e1c5c82
2 changed files with 31 additions and 4 deletions
|
@ -8,6 +8,21 @@
|
|||
{% for section in sections %}
|
||||
{{ section.form.media.js }}
|
||||
{% endfor %}
|
||||
<script type="text/javascript">
|
||||
postcode_label = $("label[for='id_profile-state']");
|
||||
postcode_help = $("#id_profile-state + p");
|
||||
$('#id_profile-country').change(function () {
|
||||
if ($(this).val() == 'AU' ) {
|
||||
postcode_label.addClass('label-required');
|
||||
postcode_help.show();
|
||||
} else {
|
||||
postcode_label.removeClass('label-required');
|
||||
postcode_help.hide();
|
||||
} });
|
||||
$("#id_profile-country").change();
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
@ -8,13 +8,25 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block scripts_extra %}
|
||||
{{ form.media.js }}
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
{{ form.media.js }}
|
||||
<script type="text/javascript">
|
||||
postcode_label = $("label[for='id_profile-state']");
|
||||
postcode_help = $("#id_profile-state + p");
|
||||
$('#id_profile-country').change(function () {
|
||||
if ($(this).val() == 'AU' ) {
|
||||
postcode_label.addClass('label-required');
|
||||
postcode_help.show();
|
||||
} else {
|
||||
postcode_label.removeClass('label-required');
|
||||
postcode_help.hide();
|
||||
} });
|
||||
$("#id_profile-country").change();
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
THIS IS THE FORM
|
||||
<form class="form-horizontal" method="post" action="">
|
||||
{% csrf_token %}
|
||||
|
||||
|
|
Loading…
Reference in a new issue