限制按鈕提交js

2021-07-22 12:21:12 字數 2499 閱讀 8106

/**

* 擴充套件jquery ajax

*///擴充套件load方法,增加timout處理

jquery.fn.singletimeload = function(url, params, callback)

if (jquery.isfunction(params)) else if (params && typeof params === "object")

if (self.length > 0) ).done( function( responsetext ) ).always( callback && function( jqxhr, status ) else );

}} );

}return this;

}//擴充套件load方法,增加loading

jquery.fn.singleload = function(url, params, callback)

if (jquery.isfunction(params)) else if (params && typeof params === "object")

if (self.length > 0) ).done( function( responsetext ) ).always( callback && function( jqxhr, status ) );

} );

}return this;

}//擴充套件ajaxsubmit方法

jquery.fn.singleajaxsubmit = function(options);

}else if ( options === undefined ) ;

}var oldcomplete = options.complete;

options.complete = removedeferred;

if (oldcomplete && typeof oldcomplete == 'function')

}method = options.type || self.attr2('method');

action = options.url  || self.attr2('action');

var href = window.location.href;

var sid = getsid( href, action );

var deferred = jquery._single_r[sid];

if (deferred)

}jquery.singleloading();//顯示圈圈

deferred = jquery._single_r[sid] = $.deferred();//鎖住請求

return self.ajaxsubmit(options);

function removedeferred()catch(err)

}function getsid(href, uri)

function hashcode(str)

return hash;}}

//擴充套件jquery ajax,同一時間同乙個頁面(根據請求url)只允許一次提交.

jquery.extend(,

singleloading : function()

},singleremove : function(),

singleajax : function( url, options )

_this._single_r = (_this._single_r ? _this._single_r : {});

var surl= (url ? url : options.url);

var href = window.location.href;

var sid = getsid( href, surl);

var deferred = _this._single_r[sid];

if (deferred)

}jquery.singleloading();//顯示圈圈

deferred = _this._single_r[sid] = $.deferred();//鎖住請求

deferred = _this._single_r[sid] = $.ajax( url, options );//請求

//正在提交

deferred.always(function());

deferred.always(function());

return deferred;

function getsid(href, uri)

function hashcode(str)

return hash;}},

singlepost : function( url, data, callback, type )

return $.singleajax( $.extend( , $.isplainobject( url ) && url ) );

}});

//關閉ajax相應的快取方法

jquery.ajaxsetup ();

yii form 表單提交之前JS在提交按鈕的驗證

很多時候,需要對yii表單model中的物件設定的rules進行判斷,但是有的時候可能需要在提交之前就在客戶端進行驗證,我這邊設定的方法是在提交按鈕上設定 如果部分內容為空 比如多選按鈕沒有選擇 那麼提示出錯資訊。主要目的是頁面不用提交後重新整理,進入controller的對應函式之後再判斷出錯。顯...

HTML常用提交按鈕

1.標籤 元素 disabled 不可操作 readonly 唯讀 placeholder 提示文字 autofocus 自動獲焦 autocomplete on 預設。規定啟用自動完成功能 off禁用自動完成功能 2.文字框 3.密碼框 4.隱藏域 5.單選框 男女 6.多選框 遊戲遊戲 點字選睡...

邊框 盒子陰影 提交按鈕

邊框線為2畫素 border width 2px 邊框線為虛線 border style dashed 邊框線為實線 border style solid 邊框圓角 border radius 10 注意 正圓必須占用一半以上 box shadow 10px 10px 10px 10px yello...