{% extends "id_creator/id_creator_base.html" %}

{% block form_page_header %}
<h1>Poll date</h1>
{% endblock form_page_header %}


{% block extra_javascript %}
{{ block.super }}
<script>
fallback.ready(function() {
    var day = $('#id_date-date_0');
    var month = $('#id_date-date_1');
    var year = $('#id_date-date_2');

    var CheckDOW = function () {
        if (day.val().length >= 1) {
            if (month.val().length >= 1) {
                if (year.val().length == 4) {
                    d = new Date([year.val(), month.val(), day.val(),].join('-'))
                    if (d.getDay() != 4) {
                        NotThursdayWarning('add', d);
                    } else {
                        NotThursdayWarning('remove', d);
                    }
                }
            }
        }
    }

    var NotThursdayWarning = function (method, date) {
        $('.date_warning').remove();
        if (method == 'add') {
            var date_string = date.format("mmmm dS yyyy");
            var day = date.format("dddd");
            $('.form-date').append('<div class="error date_warning" style="clear:both">UK elections are almost always on a Thursday<br>'+date_string+' is a '+ day +' not a Thursday. Are you sure that\'s right?</div>')
        }

    }

    $('.form-date').on('change keyup', CheckDOW);
});

</script>
{% endblock extra_javascript %}

{% extends "id_creator/id_creator_base.html" %}

{% block form_page_header %}
<h1>Poll date</h1>
{% endblock form_page_header %}


{% block extra_javascript %}
{{ block.super }}
<script>
fallback.ready(function() {
    var day = $('#id_date-date_0');
    var month = $('#id_date-date_1');
    var year = $('#id_date-date_2');

    var CheckDOW = function () {
        if (day.val().length >= 1) {
            if (month.val().length >= 1) {
                if (year.val().length == 4) {
                    d = new Date([year.val(), month.val(), day.val(),].join('-'))
                    if (d.getDay() != 4) {
                        NotThursdayWarning('add', d);
                    } else {
                        NotThursdayWarning('remove', d);
                    }
                }
            }
        }
    }

    var NotThursdayWarning = function (method, date) {
        $('.date_warning').remove();
        if (method == 'add') {
            var date_string = date.format("mmmm dS yyyy");
            var day = date.format("dddd");
            $('.form-date').append('<div class="error date_warning" style="clear:both">UK elections are almost always on a Thursday<br>'+date_string+' is a '+ day +' not a Thursday. Are you sure that\'s right?</div>')
        }

    }

    $('.form-date').on('change keyup', CheckDOW);
    CheckDOW()
});

</script>
{% endblock extra_javascript %}

Call CheckDOW on page load
Call CheckDOW on page load
