JQuery validate: validator.elementValue is not a function
<p>I have two fields in my form which I want one of them to be filled. I've found a <code>JQuery validate</code> plugin but <code>require_from_group</code> seems not working. </p>

<p>Console in inspect returns: </p>

<pre><code>Uncaught TypeError: validator.elementValue is not a function
</code></pre>

<p>The first thing I did is append class to desired fields <code>grouprequired</code>.</p>

<p>Now I have JS file; the <code>short_description</code> and <code>language_from</code> validation worked perfectly until I've added checking <code>text_to_translate</code> and <code>file</code> validations.</p>

<p>Do you know where is the problem?</p>

<pre><code>$(function () {
    jQuery.validator.setDefaults({
        debug: true,
        success: "valid"
    });

    $("#job_creation_form").validate({
        rules: {
            short_description: {
                required: true
            },
            language_from: {
                required: true
            },
            text_to_translate: {
                require_from_group: [1, '.grouprequired']
            },
            file: {
                require_from_group: [1, '.grouprequired']
            }
        },

        messages: {
            short_description: {
                required: "Short description can't be empty. Please fill this field."
            },
            language_from: {
                required: "Please choose current language."
            },
            text_to_translate: {
                require_from_group: "Either fill this form with a text or attach a file (below)."
            },
            file: {
                require_from_group: "Either attach a file or fill text to translate (above)."
            }
        }
    });
    $.validator.addMethod("require_from_group", function (value, element, options) {
        alert('kosd')
        var $fields = $(options[1], element.form),
            $fieldsFirst = $fields.eq(0),
            validator = $fieldsFirst.data("valid_req_grp") ? $fieldsFirst.data("valid_req_grp") : $.extend({}, this),
            isValid = $fields.filter(function () {
                    return validator.elementValue(this);
                }).length &gt;= options[0];

        // Store the cloned validator for future validation
        $fieldsFirst.data("valid_req_grp", validator);

        // If element isn't being validated, run each require_from_group field's validation rules
        if (!$(element).data("being_validated")) {
            $fields.data("being_validated", true);
            $fields.each(function () {
                validator.element(this);
            });
            $fields.data("being_validated", false);
        }
        return isValid;
    }, $.validator.format("Please fill at least {0} of these fields."));
});
</code></pre>

<p>Before the red line in console, there is this:</p>

<pre><code>jquery.validate.min.js:29 exception occured when checking element id_text_to_translate, check the 'require_from_group' method TypeError: validator.elementValue is not a function(…)
</code></pre>

<p>EDIT: This is an actual HTML of the form:</p>

<pre><code>&lt;form id="job_creation_form" action="" method="post" enctype="multipart/form-data" novalidate="novalidate"&gt;&lt;input
        type="hidden" name="csrfmiddlewaretoken" value="249lrU6KpGBGmDp7ezM7ApU3jGLOvBnY"&gt;


    &lt;div id="div_id_short_description" class="control-group"&gt;&lt;label for="id_short_description"
                                                                    class="control-label requiredField"&gt;
        Short description&lt;span class="asteriskField"&gt;*&lt;/span&gt; &lt;/label&gt;
        &lt;div class="controls"&gt;&lt;input class="textinput textInput" id="id_short_description" maxlength="40"
                                     name="short_description" type="text"&gt;
            &lt;p id="hint_id_short_description" class="help-block"&gt;Very short description of this order&lt;/p&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div id="div_id_language_from" class="control-group"&gt;&lt;label for="id_language_from"
                                                                class="control-label requiredField"&gt;
        Language from&lt;span class="asteriskField"&gt;*&lt;/span&gt; &lt;/label&gt;
        &lt;div class="controls"&gt;&lt;select class="select" id="id_language_from" name="language_from"&gt;
            &lt;option value="" selected="selected"&gt;---------&lt;/option&gt;
            &lt;option value="45"&gt;Slovak&lt;/option&gt;
            &lt;option value="46"&gt;Russian&lt;/option&gt;
            &lt;option value="47"&gt;Magyar&lt;/option&gt;
            &lt;option value="48"&gt;English&lt;/option&gt;
            &lt;option value="49"&gt;Croatian&lt;/option&gt;
            &lt;option value="50"&gt;Spanish&lt;/option&gt;
            &lt;option value="51"&gt;Dutch&lt;/option&gt;
            &lt;option value="52"&gt;Estonian&lt;/option&gt;
        &lt;/select&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div id="div_id_text_to_translate" class="control-group"&gt;&lt;label for="id_text_to_translate" class="control-label "&gt;
        Text to translate
    &lt;/label&gt;
        &lt;div class="controls"&gt;&lt;textarea class="grouprequired textarea" cols="40" id="id_text_to_translate"
                                        name="text_to_translate" placeholder="Specification" rows="10"&gt;&lt;/textarea&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div id="div_id_file" class="control-group"&gt;&lt;label for="id_file" class="control-label "&gt;
        File
    &lt;/label&gt;
        &lt;div class="controls"&gt;&lt;input class="grouprequired clearablefileinput" id="id_file" name="file" type="file"&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;div id="div_id_notes" class="control-group"&gt;&lt;label for="id_notes" class="control-label requiredField"&gt;
        Notes&lt;span class="asteriskField"&gt;*&lt;/span&gt; &lt;/label&gt;
        &lt;div class="controls"&gt;&lt;textarea class="textarea" cols="40" id="id_notes" name="notes" rows="10"&gt;&lt;/textarea&gt;
            &lt;p id="hint_id_notes" class="help-block"&gt;Notes&lt;/p&gt;&lt;/div&gt;
    &lt;/div&gt;


    &lt;input id="id_form-TOTAL_FORMS" name="form-TOTAL_FORMS" type="hidden" value="5"&gt;&lt;input id="id_form-INITIAL_FORMS"
                                                                                           name="form-INITIAL_FORMS"
                                                                                           type="hidden"
                                                                                           value="0"&gt;&lt;input
            id="id_form-MIN_NUM_FORMS" name="form-MIN_NUM_FORMS" type="hidden" value="0"&gt;&lt;input
            id="id_form-MAX_NUM_FORMS" name="form-MAX_NUM_FORMS" type="hidden" value="5"&gt;

    &lt;input type="hidden" name="csrfmiddlewaretoken" value="249lrU6KpGBGmDp7ezM7ApU3jGLOvBnY"&gt;
    &lt;label for="id_form-0-language"&gt;Language:&lt;/label&gt;&lt;select class="select-language" id="id_form-0-language"
                                                             name="form-0-language"&gt;
        &lt;option value="" selected="selected"&gt;---------&lt;/option&gt;
        &lt;option value="45"&gt;Slovak&lt;/option&gt;
        &lt;option value="46"&gt;Russian&lt;/option&gt;
        &lt;option value="47"&gt;Magyar&lt;/option&gt;
        &lt;option value="48"&gt;English&lt;/option&gt;
        &lt;option value="49"&gt;Croatian&lt;/option&gt;
        &lt;option value="50"&gt;Spanish&lt;/option&gt;
        &lt;option value="51"&gt;Dutch&lt;/option&gt;
        &lt;option value="52"&gt;Estonian&lt;/option&gt;
    &lt;/select&gt;
    &lt;label for="id_form-0-level"&gt;Level:&lt;/label&gt;&lt;select id="id_form-0-level" name="form-0-level"&gt;
        &lt;option value="" selected="selected"&gt;---------&lt;/option&gt;
        &lt;option value="34"&gt;Unknown&lt;/option&gt;
        &lt;option value="35"&gt;Standard level&lt;/option&gt;
        &lt;option value="36"&gt;Professional level&lt;/option&gt;
        &lt;option value="37"&gt;Native speaker level&lt;/option&gt;
    &lt;/select&gt;
    &lt;br&gt;
    &lt;br&gt;

    &lt;input type="hidden" name="csrfmiddlewaretoken" value="249lrU6KpGBGmDp7ezM7ApU3jGLOvBnY"&gt;
    &lt;label for="id_form-1-language"&gt;Language:&lt;/label&gt;&lt;select class="select-language" id="id_form-1-language"
                                                             name="form-1-language"&gt;
        &lt;option value="" selected="selected"&gt;---------&lt;/option&gt;
        &lt;option value="45"&gt;Slovak&lt;/option&gt;
        &lt;option value="46"&gt;Russian&lt;/option&gt;
        &lt;option value="47"&gt;Magyar&lt;/option&gt;
        &lt;option value="48"&gt;English&lt;/option&gt;
        &lt;option value="49"&gt;Croatian&lt;/option&gt;
        &lt;option value="50"&gt;Spanish&lt;/option&gt;
        &lt;option value="51"&gt;Dutch&lt;/option&gt;
        &lt;option value="52"&gt;Estonian&lt;/option&gt;
    &lt;/select&gt;
    &lt;label for="id_form-1-level"&gt;Level:&lt;/label&gt;&lt;select id="id_form-1-level" name="form-1-level"&gt;
        &lt;option value="" selected="selected"&gt;---------&lt;/option&gt;
        &lt;option value="34"&gt;Unknown&lt;/option&gt;
        &lt;option value="35"&gt;Standard level&lt;/option&gt;
        &lt;option value="36"&gt;Professional level&lt;/option&gt;
        &lt;option value="37"&gt;Native speaker level&lt;/option&gt;
    &lt;/select&gt;
    &lt;br&gt;
    &lt;br&gt;

    &lt;input type="hidden" name="csrfmiddlewaretoken" value="249lrU6KpGBGmDp7ezM7ApU3jGLOvBnY"&gt;
    &lt;label for="id_form-2-language"&gt;Language:&lt;/label&gt;&lt;select class="select-language" id="id_form-2-language"
                                                             name="form-2-language"&gt;
        &lt;option value="" selected="selected"&gt;---------&lt;/option&gt;
        &lt;option value="45"&gt;Slovak&lt;/option&gt;
        &lt;option value="46"&gt;Russian&lt;/option&gt;
        &lt;option value="47"&gt;Magyar&lt;/option&gt;
        &lt;option value="48"&gt;English&lt;/option&gt;
        &lt;option value="49"&gt;Croatian&lt;/option&gt;
        &lt;option value="50"&gt;Spanish&lt;/option&gt;
        &lt;option value="51"&gt;Dutch&lt;/option&gt;
        &lt;option value="52"&gt;Estonian&lt;/option&gt;
    &lt;/select&gt;
    &lt;label for="id_form-2-level"&gt;Level:&lt;/label&gt;&lt;select id="id_form-2-level" name="form-2-level"&gt;
        &lt;option value="" selected="selected"&gt;---------&lt;/option&gt;
        &lt;option value="34"&gt;Unknown&lt;/option&gt;
        &lt;option value="35"&gt;Standard level&lt;/option&gt;
        &lt;option value="36"&gt;Professional level&lt;/option&gt;
        &lt;option value="37"&gt;Native speaker level&lt;/option&gt;
    &lt;/select&gt;
    &lt;br&gt;
    &lt;br&gt;

    &lt;input type="hidden" name="csrfmiddlewaretoken" value="249lrU6KpGBGmDp7ezM7ApU3jGLOvBnY"&gt;
    &lt;label for="id_form-3-language"&gt;Language:&lt;/label&gt;&lt;select class="select-language" id="id_form-3-language"
                                                             name="form-3-language"&gt;
        &lt;option value="" selected="selected"&gt;---------&lt;/option&gt;
        &lt;option value="45"&gt;Slovak&lt;/option&gt;
        &lt;option value="46"&gt;Russian&lt;/option&gt;
        &lt;option value="47"&gt;Magyar&lt;/option&gt;
        &lt;option value="48"&gt;English&lt;/option&gt;
        &lt;option value="49"&gt;Croatian&lt;/option&gt;
        &lt;option value="50"&gt;Spanish&lt;/option&gt;
        &lt;option value="51"&gt;Dutch&lt;/option&gt;
        &lt;option value="52"&gt;Estonian&lt;/option&gt;
    &lt;/select&gt;
    &lt;label for="id_form-3-level"&gt;Level:&lt;/label&gt;&lt;select id="id_form-3-level" name="form-3-level"&gt;
        &lt;option value="" selected="selected"&gt;---------&lt;/option&gt;
        &lt;option value="34"&gt;Unknown&lt;/option&gt;
        &lt;option value="35"&gt;Standard level&lt;/option&gt;
        &lt;option value="36"&gt;Professional level&lt;/option&gt;
        &lt;option value="37"&gt;Native speaker level&lt;/option&gt;
    &lt;/select&gt;
    &lt;br&gt;
    &lt;br&gt;

    &lt;input type="hidden" name="csrfmiddlewaretoken" value="249lrU6KpGBGmDp7ezM7ApU3jGLOvBnY"&gt;
    &lt;label for="id_form-4-language"&gt;Language:&lt;/label&gt;&lt;select class="select-language" id="id_form-4-language"
                                                             name="form-4-language"&gt;
        &lt;option value="" selected="selected"&gt;---------&lt;/option&gt;
        &lt;option value="45"&gt;Slovak&lt;/option&gt;
        &lt;option value="46"&gt;Russian&lt;/option&gt;
        &lt;option value="47"&gt;Magyar&lt;/option&gt;
        &lt;option value="48"&gt;English&lt;/option&gt;
        &lt;option value="49"&gt;Croatian&lt;/option&gt;
        &lt;option value="50"&gt;Spanish&lt;/option&gt;
        &lt;option value="51"&gt;Dutch&lt;/option&gt;
        &lt;option value="52"&gt;Estonian&lt;/option&gt;
    &lt;/select&gt;
    &lt;label for="id_form-4-level"&gt;Level:&lt;/label&gt;&lt;select id="id_form-4-level" name="form-4-level"&gt;
        &lt;option value="" selected="selected"&gt;---------&lt;/option&gt;
        &lt;option value="34"&gt;Unknown&lt;/option&gt;
        &lt;option value="35"&gt;Standard level&lt;/option&gt;
        &lt;option value="36"&gt;Professional level&lt;/option&gt;
        &lt;option value="37"&gt;Native speaker level&lt;/option&gt;
    &lt;/select&gt;
    &lt;br&gt;
    &lt;br&gt;

    &lt;button value="Update" type="submit"&gt;Submit&lt;/button&gt;
&lt;/form&gt;
</code></pre>