Event Listeners Not Detaching - Creating Multiple Events For Same Element

I'm still having issues with the below code. When I test the page, the top code will run as expected. Once I invoke the bottom code which is attached to a text input field, the event listeners still seem to not be removed as each time I test the field, it will proportionately run the code that many times. So for the bottom code I should get only 2 console logs each time (which happens the first time) but if I change the text in the input field a second time, the function runs twice and I get 4 console logs. If I test again then the code runs 3 times and I get 6 console logs. If I then go back to the top piece of code and test that one again it will then run 4 times and I'll get 8 console logs?  I'm totally confused as to how to fix this? The code is invoked each time someone focuses on one of the elements in the code. I have to inject this code via a Tag Manager (DTM) using an event based rule.
var employmentStatusSelect = document.getElementById('mainForm:cont_appRequest_customers__0_employmentStatus:decoin:appRequest_customers__0_employmentStatus');

employmentStatusSelect.removeEventListener('change', trackEmploymentStatusSelect);
employmentStatusSelect.addEventListener('change',trackEmploymentStatusSelect);

function trackEmploymentStatusSelect (){
    var esSelVal = event.target.value;
    console.log(" event.target.value ==> " + event.target.value);
    if(esSelVal != ""){
        console.log("employmentStatusSelect ==> " + event.target.value);  
    } else {
       console.log("employmentStatusSelect will not report");
    }
};

var startCurrentJobInput = document.getElementById('mainForm:cont_appRequest_customers__0_records_ichabod_fields__0_columns_start_job:decoin:appRequest_customers__0_records_ichabod_fields__0_columns_start_job');

startCurrentJobInput.removeEventListener('blur', trackStartCurrentJobInput)
startCurrentJobInput.addEventListener('blur', trackStartCurrentJobInput);

function trackStartCurrentJobInput(){
    var scjVal = event.target.value;
    console.log(" event.target.value ==> " + event.target.value);
    if(scjVal != ""){
        console.log("startCurrentJobInput ==> " + event.target.value);  
    } else {
       console.log("startCurrentJobInput will not report");
    }
};

Open in new window

Thanks!
894359Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

894359Author Commented:
I figured it out. Since this is done via a Tag Management System, The rule is an event-based rule which fires onFocus of the form. This essentially reruns the code and if I don't kill all event listeners then they remain, giving me the weird results.
894359Author Commented:
I figured it out. Since this is done via a Tag Management System, The rule is an event-based rule which fires onFocus of the form. This essentially reruns the code and if I don't kill all event listeners then they remain, giving me the weird results.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.