How to stop execution of js script?

Greetings to all.
I need to write js script that will read the user's nick to the cookie file. If not, it should appear a modal form into which the user enters his nickname and which are recorded in cookies. The problem is that js doesn't want to stop its execution so that the user can enter his nickname into the form and returns an empty value. How to stop execution of js script while the user enters his nickname and click on send button? Or please provide another way to solve this problem. Thanks in advance.
June 8th 19 at 16:44
3 answers
June 8th 19 at 16:46
Solution
document.querySelector('input').addEventListener('change', function(e){
// Your code
}
Subscribe to the change event for the input field, this event will come when the user ceases to input data and takes away the focus.
Sounds like a great thing these EventListener's. Thank you. - merlin_Lockm commented on June 8th 19 at 16:49
please was happy) Yeah, no eventListener anywhere. - Verda_Gibson13 commented on June 8th 19 at 16:52
June 8th 19 at 16:48
setTimeout and setInterval tried?
June 8th 19 at 16:50
How do I know for sure how long a user enter your nickname to be?

Find more questions by tags JavaScriptHTTP Cookies