title: Uncaught TypeError: Cannot read property 'addEventListener' of undefined in chained prototype function
body: <p>I'm currently developing a small validation script at <a href="http://mandala.morgana-design.com/contacto" rel="nofollow noreferrer">http://mandala.morgana-design.com/contacto</a> and am facing a few log errors through the chrome inspect tool. </p>
  
  <p>It is not recognizing the parameter <code>input</code> in the prototype chain function. Despite the form functioning as it should, I still would like to correct these errors. Any advice is appreciated.</p>
  
  <pre><code>main.js?1499689891:178 Uncaught TypeError: Cannot read property 'addEventListener' of undefined
      at Validation.bindEvents (main.js?1499689891:178)
      at Validation.init (main.js?1499689891:133)
      at new Validation (main.js?1499689891:121)
      at main.js?1499689891:264
      at main.js?1499689891:269
  </code></pre>
  
  <p>Part of the code that receives the errors :</p>
  
  <pre><code>    (function(window, document, undefined) {"use strict";
          Validation.prototype.bindEvents = function(input, button) {
          var required = this.options.required, valid = this.options.valid, invalid = this.options.invalid;
  
          document.addEventListener('DOMContentLoaded', function(){
              this.validate();
          }.bind(this));
  
          input.addEventListener('keyup', function(){
              if(input.classList.contains(invalid) || input.classList.contains(valid)){this.inspect(input);}
              if(!input.classList.contains(required) &amp;&amp; this.trim(input.value) === ""){
                  input.className = "";
              }
          }.bind(this));
  
          input.addEventListener('blur', function(){
              if(this.trim(input.value) !== "" || input.classList.contains(required)){this.inspect(input);}
          }.bind(this));
          input.addEventListener('focus', function(){
                  button.className = "";
          }.bind(this));
  
  
          if(input.type === "radio" &amp;&amp; input.name === "radio_destination"){
              var field = document.getElementById("destination");
  
              input.addEventListener('click',function(){
                  if(input.checked &amp;&amp; input.id === "yes"){
                      this.radioButton(input);
                  }else{
                      field.value = "";
                      field.className = "";
                  }
              }.bind(this));
  
              if(input.checked) {
                  if(input.id === "yes") {
                      field.className = required;
                  }else {
                      field.value = "";
                      field.className = "";
                  }
              }
  
  
      }
  
      if(this.trim(input.value) !== "" ) {this.inspect(input);}};
  })(window, document);
  </code></pre>
  
  <p>Apologies if this post is not transparent enough, I don't use stackoverflow that often.</p>
  
  <p>Thanks in advance</p>