Tried Many nothing working Out.
Need to prevent button from double click.
need to enable false as soon ias it got clicked an need to enable true as soon as completion of clickEvent
<asp:Button ID="btnSave" runat="server" CssClass="button" TabIndex="10" Text="<%$ Resources:LocalStrings,Save %>" OnClientClick="return validate()" OnClick="btnSave_Click" />
on page load
btnSave.Attributes.Add("onclick", " this.disabled = true; " + ClientScript.GetPostBackEventReference(btnSave, null) + ";");
javscript method validate..
function validate() {
if (document.getElementById('<%=ddlstocktype.ClientID%>').selectedIndex == 0) {
alert('<%= Resources.LocalStrings.SelectStockType %>');
$(document.activeElement).bind('click', function () {
document.getElementById('<%=ddlstocktype.ClientID%>').focus();
});
return false;
}
else if (document.getElementById('<%=ddllibdept.ClientID%>').selectedIndex == 0) {
alert('<%= Resources.LocalStrings.SelectDepartment %>');
$(document.activeElement).bind('click', function () {
document.getElementById('<%=ddllibdept.ClientID%>').focus();
});
return false;
}
else if (document.getElementById('<%=ddllibsect.ClientID%>').selectedIndex == 0) {
alert('<%= Resources.LocalStrings.PleaseSelectSector %>');
$(document.activeElement).bind('click', function () {
document.getElementById('<%=ddllibsect.ClientID%>').focus();
});
return false;
}
else if (document.getElementById('<%=txtName.ClientID%>').value.trim().length == 0) {
alert('<%= Resources.LocalStrings.EnterName %>');
$(document.activeElement).bind('click', function () {
document.getElementById('<%=txtName.ClientID%>').focus();
});
return false;
}
else if (document.getElementById('<%=txtName.ClientID%>').value == "Please Select") {
alert('<%= Resources.LocalStrings.SelectBookTitle %>');
$(document.activeElement).bind('click', function () {
document.getElementById('<%=ddlbook.ClientID%>').focus();
});
return false;
}
else if (document.getElementById('<%=ddlbooktype.ClientID%>').selectedIndex == 0) {
alert('<%= Resources.LocalStrings.PleaseSelectBookType %>');
$(document.activeElement).bind('click', function () {
document.getElementById('<%=ddlbooktype.ClientID%>').focus();
});
return false;
}
else if (document.getElementById('<%=ddlauthor.ClientID%>').selectedIndex == 0) {
alert('<%= Resources.LocalStrings.SelectAuthor %>');
$(document.activeElement).bind('click', function () {
document.getElementById('<%=ddlauthor.ClientID%>').focus();
});
return false;
}
else if (document.getElementById('<%=ddledition.ClientID%>').selectedIndex == 0) {
alert('<%= Resources.LocalStrings.EnterEdition %>');
$(document.activeElement).bind('click', function () {
document.getElementById('<%=ddledition.ClientID%>').focus();
});
return false;
}
else if (document.getElementById('<%=txtPrice.ClientID%>').value.trim().length == 0) {
alert('<%= Resources.LocalStrings.EnterPrice %>');
$(document.activeElement).bind('click', function () {
document.getElementById('<%=txtPrice.ClientID%>').focus();
});
return false;
}
else if (document.getElementById('<%=txtcopies.ClientID%>').value.trim().length == 0) {
alert('<%= Resources.LocalStrings.EnterNoofCopies %>');
$(document.activeElement).bind('click', function () {
document.getElementById('<%=txtcopies.ClientID%>').focus();
});
return false;
}
}