A
A
AL_32018-02-02 14:27:51
JavaScript
AL_3, 2018-02-02 14:27:51

How to stop js script execution?

Welcome all.
I need to write a js script that will read the user's nickname from cookies. If it is not there, then a modal form should appear in which the user will enter his nickname and which will be recorded in cookies. The problem is that js does not want to stop its execution so that the user can enter his nickname in the form and returns an empty value. How to stop the execution of a js script for a while until the user enters his nickname and clicks on the submit button? Or please indicate another way to solve this problem. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dima Polos, 2018-02-02
@AL_3

document.querySelector('input').addEventListener('change', function(e){
// Your code
}
Subscribe to the change event for the input field, this event will fire when the user stops typing and removes focus.

V
Vladislav Prubnyak, 2018-02-02
@Vaprubnyak

have you tried setTimeout and setInterval?

A
AL_3, 2018-02-02
@AL_3

And how can I know for sure how long the user will enter his nickname?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question