Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use JS to realize automatic countdown of 30 seconds before the button is available

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

How to use JS to achieve automatic countdown of 30 seconds before the button is available, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Countdown is often used in WEB development to restrict users' operations on the form, such as allowing users to read the relevant protocol information within a certain period of time before allowing users to proceed to the next step, or allowing users to obtain verification codes again after a certain period of time (without receiving the verification code) when collecting the mobile verification code. So today I'm going to show you how to use Javascript to implement this simple application.

Application scenario 1: users can not activate the button until they have read the relevant protocol information when they register.

When registering on some websites, users are required to agree to information such as the so-called user agreement, and if the content of the agreement is very important, some sites require newly registered users to read the relevant agreement information before activating the next button to submit the form. In order to allow users to read the agreement information (I don't know whether the actual users have actually read it or not), developers will design a countdown such as 30 seconds before the form submit button will be activated. Let's see how to implement it.

Suppose there is such a form above, the rest of the form is omitted, there is only a submit button, the button is not available at first, when the 30-second countdown is over, the button will display "I agree" and you can click to activate.

We use native js to achieve this effect:

Var secs = 30; document.agree.agreeb.disabled=true; for (var item1teri)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report