Button functionality works smoothly on desktop but experiences issues with multiple submissions on mobile devices such as iPhones

Preventing multiple form submissions in asp.net webform functions correctly on a desktop version, but encounters issues on the mobile version of Safari or Chrome on iPhone.

The following script prevents users from submitting the same form multiple times by changing the text of the submit button to "wait..." after the form has been submitted and validated successfully.

While this script works well on desktops, it fails to update the button text to "wait..." on the default iPhone browser or Chrome. The reason for this issue is unclear, and troubleshooting has been unsuccessful so far.

BUTTON

<asp:Button ID="btnSave" runat="server" Text="Submit" CausesValidation="true" CssClass="btn btn-primary" ValidationGroup="vgForm" OnClick="btnSave_Click" OnClientClick="ClientSideClick(this)" UseSubmitBehavior="False" />

 <asp:Button ID="btnSave" runat="server" Text="Submit" CausesValidation="true" CssClass="btn btn-primary" ValidationGroup="vgForm" OnClick="btnSave_Click" OnClientClick="ClientSideClick(this)" UseSubmitBehavior="False" />


  //Avoid Multiple Submission
        function ClientSideClick(myButton) {
            // Client side validation
            if (typeof (Page_ClientValidate) == 'function') {
                if (Page_ClientValidate("vgForm") == false) {
                    return false;
                }
            }

            // Ensure the button is not of type "submit" but "button"
            if (myButton.getAttribute('type') == 'button') {
                // Disable the button
                myButton.disabled = true;
                myButton.className = "btn-inactive";
                myButton.value = "Wait...";
            }
            return true;
        }

Answer №1

To prevent multiple submissions, the button can be deactivated after being clicked.

<input id="btnSubmit" type="submit" onclick="this.disabled = true; this.value= 'wait...'" value="Submit">

If there is a success callback, the button can be reactivated.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issues arise when jQuery functions do not execute as expected within an "if" statement following

Recently, I delved into the realm of AJAX and embarked on a journey to learn its intricacies. Prior to seeking assistance here, I diligently scoured through past queries, such as this, but to no avail. Here is an excerpt from my code: $('.del'). ...

Function invoking React Hook

I'm a beginner to React JS and I've been learning by working on a project. I was creating a basic e-commerce UI with items and attempting to add items to a cart, but encountered an issue. The React Hook "useStateValue" is being called in the fun ...

Controlling the Flow of Events in JavaScript Documents

Explore the integration of two interconnected Javascript files and delve into managing event propagation between them effectively. 1st js file var red = [0, 100, 63]; var orange = [40, 100, 60]; var green = [75, 100, 40]; var blue = [196, 77, 55]; var ...

How do I incorporate an external template in Mustache.js?

Welcome, I am a beginner in using Mustache.js. Below is the template and JS code that I have: var template = $('#pageTpl').html(); var html = Mustache.to_html(template, data); $('#sampleArea').html(html); Here is the template ...

Displaying the contents of a local HTML file in a div

I am attempting to load a local HTML file into a div, however it is not displaying any content on the page despite showing an alert. Here is the HTML code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> ...

Using React.js to create a search filter for users

When using useEffect with fetch(api) to set [search], I encounter an issue where "loading..." appears each time I enter something in the input box. To continue typing, I have to click on the box after every word or number. I am seeking advice on how to pr ...

Jquery UI slider malfunctioning would require troubleshooting

I am currently working on implementing slider functionality with jQuery. The slider is visible and functioning properly in terms of taking in values, however, the values are not displayed on the screen as expected. I have used console.log to track the ui.v ...

Utilizing Asp.Net 4.0 gridview for displaying the value of the Display attribute

I've been working on displaying a list in a gridview where AutoGenerateColumns is set to true. This particular class has over 70 properties, which is quite extensive. Now, I'm looking to change the column header names in the gridview. For insta ...

What is the process for printing a formview page?

Is it possible to create a routine for printing pages with a formview table, similar to how it's done with a gridview? Can the existing routine be modified to work with formview by changing GridView1 to FormView1? Please note that this will only work ...

Using Vue to fetch JSON data with Axios

When trying to retrieve user data from a MongoDB in JSON format using axios.get within a Vue.js application, my aim is to visualize this data by iterating through all user objects in the users array. The issue I'm facing is that each character is trea ...

Troubleshoot: Problem with the name attribute in ASP.NET CheckBox control

When I use a checkbox with the attribute runat="server" in my ASP.NET web application, browsers encounter an issue: Uncaught Syntax error, unrecognized expression: [name=ctl00$ctl00$ContentPlaceHolder1$FormPlaceHolder$CrossFinancing] The ASP.NET code ...

The audio must start playing prior to being forwarded to a new page

As I delve into the world of website development on my own, I have encountered an interesting challenge. At the top of my webpage, I have embedded an audio file within a button. If the user chooses to mute the audio, the navigation links will remain silent ...

Securing child paths in Vue.js

Having trouble protecting child routes from parent routes, facing some issues export default new Router({ routes: [ //frontend routes { {path: 'auth', component: Auth, children: authroutes, beforeEnter: (to, from, n ...

Storing JSON data in an array using JavaScript is a powerful method to

Here is an example of JSON data: [{ "address": "A-D-1", "batch": [{ "batch_number": "B-123", "cost": [{ "cost": "C1" }] }] }, { "address": "A-85-1", "batch": [{ "batch_number": "B-6562", ...

Transforming a TypeScript enum into an array of objects

My enum is defined in this structure: export enum GoalProgressMeasurements { Percentage = 1, Numeric_Target = 2, Completed_Tasks = 3, Average_Milestone_Progress = 4, Not_Measured = 5 } However, I want to transform it into an object ar ...

Divide the cookies on the webpage

Today I was working on some coding tasks when I encountered an error: Cannot read properties of undefined (reading 'split') at getCookie ((index):38:49) at (index):47:31 The section of my code where the issue occurred (beginning at line ...

Ways to validate custom attributes

I have implemented a middleware in order to sanitize asp.net endpoints using HtmlSanitizer, which is detailed in this article. However, I have encountered an issue with file uploads not being sanitized. As a solution, I am exploring the use of a custom att ...

Generating random images using Javascript

I am facing some challenges while creating my first custom JavaScript function. My goal is to display three random thumbnails on my webpage by selecting images from a pool of options. However, I am encountering issues with duplicated images and handling s ...

Problem: Vue 3 build does not generate service worker

After adding the "@vue/cli-plugin-pwa": "^4.5.12" to my package.json and setting up workbox configuration in my vue.config.js, I encountered an issue. When running npm run build:prd with the script vue-cli-service build --mode prod.exam ...

Refresh a single Object Key in React.js

Hey there, I'm currently working on updating book information via a PUT request to my API. My goal is to send only one property at a time, while keeping the rest unchanged. The issue I'm facing is that if I send just one property, the others are ...