<commit_before>/* ***********************************************
 * Validates form accroding to the definition in the HTML.
 * Is automatically loaded when included in a page.
 *
 * @author <NAME> (http://github.com/oliverroick)
 * @version 0.1
 * ***********************************************/

$(function() {
    'use strict';

    var form = $('form').not('#description-form');

    /**
     * Displays a help text beneath invalid fields.
     * @param  {Object} field   The invalid field
     * @param  {String} message The message to display.
     */
    function showHelp(field, message) {
        field.siblings('.help-block').remove();
        field.after('<span class="help-block">' + message  + '</span>');
    }

    function dateTimeValid(form) {
        var valid = true;
        var dateTimeFields = $(form).find('input.datetime, input.date');

        for (var i = 0, len = dateTimeFields.length; i < len; i++) {
            var field = $(dateTimeFields[i]);

            var min = field.attr('min');
            var max = field.attr('max');

            if (min) { min = Date.parse(min.replace(' ', 'T')); }
            if (max) { max = Date.parse(max.replace(' ', 'T')); }

            var val = Date.parse(field.val().replace(' ', 'T'));

            if (field.val().length && !val) {
                valid = false;
                field.parents('.form-group').addClass('has-error');
                showHelp(field, 'The date entered could not be validated. Please check the entry.');
            } else {
                if (!(min && val ? (val > min): true)) {
                    valid = false;
                    field.parents('.form-group').addClass('has-error');
                    showHelp(field, 'The entered date must be lower than ' + field.attr('min'));<commit_msg>Enables form validation for file fields<commit_after>/* ***********************************************
 * Validates form accroding to the definition in the HTML.
 * Is automatically loaded when included in a page.
 *
 * @author <NAME> (http://github.com/oliverroick)
 * @version 0.1
 * ***********************************************/

$(function() {
    'use strict';

    var form = $('form').not('#description-form');

    /**
     * Displays a help text beneath invalid fields.
     * @param  {Object} field   The invalid field
     * @param  {String} message The message to display.
     */
    function showHelp(field, message) {
        field.siblings('.help-block').remove();
        field.parents('.form-group').append('<span class="help-block">' + message  + '</span>');
    }

    function dateTimeValid(form) {
        var valid = true;
        var dateTimeFields = $(form).find('input.datetime, input.date');

        for (var i = 0, len = dateTimeFields.length; i < len; i++) {
            var field = $(dateTimeFields[i]);

            var min = field.attr('min');
            var max = field.attr('max');

            if (min) { min = Date.parse(min.replace(' ', 'T')); }
            if (max) { max = Date.parse(max.replace(' ', 'T')); }

            var val = Date.parse(field.val().replace(' ', 'T'));

            if (field.val().length && !val) {
                valid = false;
                field.parents('.form-group').addClass('has-error');
                showHelp(field, 'The date entered could not be validated. Please check the entry.');
            } else {
                if (!(min && val ? (val > min): true)) {
                    valid = false;
                    field.parents('.form-group').addClass('has-error');
                    showHelp(field, 'The entered date must be lower than ' + field.attr('min'));
{'fraction_non_alphanumeric': 0.20531798245614036, 'fraction_numerical': 0.001644736842105263, 'mean_word_length': 2.237799467613132, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6334579', 'n_tokens_mistral': 1011, 'n_tokens_neox': 972, 'n_words': 274}