Pages

Thursday, August 30, 2012

Prevent double click using Jquery

$(document).ready(function(){
       
            $('#ctl00_hdnPostbackInProgress').val('0');
           
            $('.Button').each(function(){
                $(this).bind('click', function(e){
                    ValidateButtonPostBack($(this), e);
                });
            });
        });
       
       
        function ValidateButtonPostBack(control , e)
        {
            if($('#ctl00_hdnPostbackInProgress').val() == '0')
            {
                $('#ctl00_hdnPostbackInProgress').val('1');
               
                if(control[0].href.indexOf("WebForm_DoPostBackWithOptions") != -1)
                {
                    var startIndex = control[0].href.indexOf("WebForm_PostBackOptions") + 'WebForm_PostBackOptions'.length + 1;
                    var valGroup = control[0].href.substr(startIndex).split(',')[3].replace(/"/g,'').replace(/ /g,'');
                    if(!Page_ClientValidate(valGroup))
                    {
                        $('#ctl00_hdnPostbackInProgress').val('0');
                    }
                }
            }
            else
            {
                e.preventDefault();
            }
        }

No comments:

Post a Comment