title: Type Error: cannot read property length of undefined for empty_value_check
body: <p>These are the javascript functions for my html form, to validate for empty values in &quot;input&quot; elements and &quot;select&quot; elements respectively. The empty_select_check function doesn't work and I'm not sure why, but the empty_value check works for the individual fields. However, it does not work in the empty_value_all() fucntion. Note that the empty_value_all() is called when the user clicks submit.
  I get the following error:</p>
  <p>Type Error: cannot read property length of undefined for empty_value_check. Any idea why it works for individual fields but not for when i try to submit? Let me know if you require my html code but basically its just input elements with an onkeyup=&quot;&quot; where I call the js functions.</p>
  <pre><code>  function submitform(){
        empty_value_all()
        $('#Start').click()
      }
    }
  
  
  function empty_value_check(ele) {
    let value = ele.value;
    console.log(value)
    if (value === '' || value.length === 0) {
      if ($(ele).closest('div').find('small').length != 0)
        $(ele).closest('div').find('small').removeClass('hide').removeClass('d-none');
      else
        $(ele).closest('div').nextAll('small').removeClass('hide').removeClass('d-none');
        $(ele).addClass('is-invalid');
    }
    else {
      $(ele).nextAll('small').addClass('hide');
      $(ele).removeClass('is-invalid');
    }
  }
  
  
  function empty_select_check(ele) {
    if (ele.value === &quot;Select Folder&quot; || ele.value === undefined) {
        $(ele).addClass('invalid-feedback');
    return false
      } else {
        $(ele).removeClass('is-invalid');
      }
  }
  
  
  $(function() {
    $('#field_5,#field_6,#field_7').on('change', empty_select_check(this))
  })
  
  function empty_value_all() {
    $('#field_1,#field_2,#field_3,#field_4').each(empty_value_check(this));
    $('#field_5,#field_6,#field_7').each(empty_select_check(this));
    return false;
  }
  
  
  </code></pre>