Timed button availability to prevent continuous submission

Source: Internet
Author: User

If you have any questions, add the QQ group.14670545Discussion

The number of 18-bit cycles: datetime. Now. ticks. tostring ()

 
<SCRIPT type = "text/JavaScript"> // $ J = jquery. noconflict (); var time_begin = new date (); var settime = 3; var I; var showthis; $ (document ). ready (function () {for (I = 1; I <= settime; I ++) {setTimeout ("Update (" + I + ")", I * 1000) ;}}); function Update (Num) {If (num = settime) {$ ("# next_button "). ATTR ("disabled", false); $ ("# surplus_time "). text ("") ;}else {showthis = settime-num; $ ("# surplus_time "). text (showthis); $ ("# next_button "). ATTR ("disabled", true) ;}</SCRIPT>

The following is a specific example:

<% @ Page Language = "C #" autoeventwireup = "true" codebehind = "pattern_memo.aspx.cs" inherits = "mywebsitetest. designpatterns. pattern_memo" %> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml"> 
Public partial class pattern_memo: system. Web. UI. Page {protected void page_load (Object sender, eventargs e) {} protected void next_button_click (Object sender, eventargs e ){}}

Note that you must add a sentence after ready of the page.

 
$ ("# Next_button"). ATTR ("disabled", true );

Otherwise, the button will be available for about one second. If you add the enabled (disabled) attribute directly to the button, the onclientclick method will not work.

Compare the results:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.