Related Tags:
Asp.Net It was developed by Microsoft to allow programmers to build dynamic web sites, web applications and web services. It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft's Active Server Pages (ASP) technology. Learn More, C# C# (pronounced "C-sharp") is an object-oriented programming language from Microsoft that aims to combine the computing power of C++ with the programming ease of Visual Basic. C# is based on C++ and contains features similar to those of Java. Learn More, JQuery JQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. Learn More, ASP.NET Web Forms ASP.NET Web Forms is a web application framework and one of several programming models supported by the Microsoft ASP.NET technology. Web Forms applications can be written in any programming language which supports the Common Language Runtime, such as C# or Visual Basic. Learn More,

How to avoid multiple submissions of a form on client side?

Description:What is happening in my case is user submit the form multiple times when form is already submitted and takes time because of the slow server response time suggestion needed to Stop or prevent form's multiple submissions on client side

Posted by: | Posted on: May 09, 2018

1 answers

Replies

1

Hi jhon,
I am assuming by your mentioned tags that you are working in asp.net so you can use following code.
In markup on client event you can call your validate() method as shown.
 
<asp:Button ID="btnsubmit" runat="server" OnClick="btnsubmit_Click" OnClientClick="return Validate();" />

Then you can update your validate() method by adding following chucks in your code.
What it will do is when your client side validation is true then it will add a class "btnDisabled" and once the class is added it will stop submitting the form again. After successful submission if it is landing on the same page then you need to explicitly remove "btnDisabled" class for next submission.
 
function Validate() {
var isValid = true;
if ($("#<%=btnsubmit.ClientID%>").hasClass("btnDisabled")) {
return false;
}
//Here you can added your client side validations
if (isValid === true) {
$("#<%=btnsubmit.ClientID%>").addClass("btnDisabled")
}
return isValid;
}

Replied by: | Replied on: May 11, 2018



Reply
×

Code block Hyperlink bold Quotes block Upload Images

Preview