Home  >  Article  >  Web Front-end  >  Some little knowledge about js and code sharing

Some little knowledge about js and code sharing

零到壹度
零到壹度Original
2018-04-14 15:06:131386browse

The content of this article is to share some small knowledge points about js and code sharing. It has a certain reference value. Friends in need can refer to it

js to prevent duplication Submit
  1. The first method returns false when clicked 2. When clicked, make the button unavailable, such as disabled

 var feedbtnlock = 0;function bonus_passwd() {
    if (feedbtnlock == 0) {
        feedbtnlock = 1;
        setTimeout(function(){
            feedbtnlock = 0;
        }, 1500);
    } else {
       alert('请勿重复点击!');       return false;
    }
}
Form validation
  1. validate 2. validfrom

<form id="add_form" method="post" enctype="multipart/form-data">
 <input type="text" name=&#39;title&#39; value=&#39;&#39;></form><script>$("#add_form").validate({
   rules : {
      title: {
                required : true
         } 
    },
    messages : {
          title: {
                required : &#39;标题不能为空&#39;
            }
    }
});</script>
js pop-up window

artdialog

  <body>
    <button data-event="test">open dialog</button>
    <script src="artDialog-master/lib/jquery-1.10.2.js"></script>
    <script src="artDialog-master/dist/dialog.js"></script>
    <script>
        $(&#39;button[data-event=test]&#39;).on(&#39;click&#39;, function() {
            var d = dialog({
                title: &#39;消息&#39;,
                content: &#39;风吹起的青色衣衫,夕阳里的温暖容颜,你比以前更加美丽,像盛开的花<br>——许巍《难忘的一天》&#39;,
                okValue: &#39;确 定&#39;,
                ok: function() {
                    var that = this;
                    setTimeout(function() {
                        that.title(&#39;提交中..&#39;);
                    }, 2000);                    return false;
                },
                follow: this,
                cancelValue: &#39;取消&#39;,
                cancel: function() {}
            });

            d.show();
        });    </script></body>

Related recommendations:

##JS pop-up window method summary

js operation form

js makes a simple div pop-up window

JS Form Validation

The above is the detailed content of Some little knowledge about js and code sharing. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn