Cannot read property 'addEventListener' of null validation input
<p>I catch the error:</p>

<blockquote>
  <p>Cannot read property 'addEventListener' of null</p>
</blockquote>

<p>I've got two events for input and for another div. Nly the input event show this error, how to prevent it? When I add this script to according page when it trigger -all good, but in main.js files I've got this error.</p>

<pre><code>&lt;form&gt;
   &lt;div class="form-row"&gt;
       &lt;label&gt;Vælg et beløb&lt;/label&gt;
          &lt;div class="doner-prices"&gt;50&lt;/div&gt;
          &lt;div class="doner-prices"&gt;100&lt;/div&gt;
          &lt;div class="doner-prices"&gt;200&lt;/div&gt;
          &lt;div class="doner-prices"&gt;500kr&lt;/div&gt;
   &lt;/div&gt;
   &lt;fieldset class="form-row"&gt;
        &lt;div class="form-col doner-price"&gt;
           &lt;label for="donate-price"&gt;
             eller angiv dit eget
            &lt;input type="text" id="donate-price" name="name" pattern="\d+" value="" required&gt;

            &lt;/label&gt;
        &lt;/div&gt;
     &lt;/fieldset&gt;
 &lt;/form&gt;   

document.addEventListener("DOMContentLoaded", function () {
    var amount_list = document.querySelectorAll('.form-row .doner-      prices'); //node-list
    var amount_array = [].slice.call(document.querySelectorAll(".form-row   .doner-prices")); //node-list to array
    var donerForm = document.getElementById('doner-hidden');
    var inputDonateField = document.getElementById('donate-price');
    var inputNumber = /^[0-9]+$/;
    var onClickFormVisible = function () {
        donerForm.style.display = "block";
    };
    var onInputTypeNumber = function () {
        if (inputNumber.test(inputDonateField.value)) {
            donerForm.style.display = "block";
        } else {
            return false;
        }
    };
    //onclick event for each amount images
    var amoutn_array = amount_array.map(function (e) {
        return e.addEventListener('click', onClickFormVisible, false);
    });
    //input event only if value === number
    inputDonateField.addEventListener("keyup", onInputTypeNumber, false);
});
</code></pre>