locked
How to prevent duplicate form submissions RRS feed

  • Question

  • Hi everyone,

    I am trying to prevent users from submitting a form twice.  At times it can take several seconds (sometimes more) for the page to change, so I want to provide some sort of feedback before the user smashes the OK button several more times.  Ideally I'd disable the button, but I'd accept some way of providing any feedback (changing the button value to 'Processing' or displaying another element/image to indicate progress).

    If I could use javascript, I'd simply place some onclick methods on the button, but unfortunately onclick is not a valid attribute of the <SharePoint:SaveButton> element.

    When I searched the forums, I found many references to preventing duplicate entries in the table -- but that is not what I'm after here.  Any ideas?


    Shawn Keene

    Friday, March 30, 2012 3:57 PM

All replies

  • small disclaimer: I haven't tested this out

    Using jQuery, I would think you can grab the button by value is equal to Save, a save button below:

    <input name="ctl00$m$g_2873e2a7_1601_431d_8be6_ab7c1d161354$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem"

    class="ms-ButtonHeightWidth" id="ctl00_m_g_2873e2a7_1601_431d_8be6_ab7c1d161354_ctl00_toolBarTbl_RightRptControls_ctl00_ctl00_diidIOSaveItem"

    accessKey="O"

    onclick="if (!PreSaveItem()) return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$m$g_2873e2a7_1601_431d_8be6_ab7c1d161354$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem", "", true, "", "", false, true))"

    type="button" target="_self" value="Save"/>


    and possibly replace the onclick event with your own that changes the button then calls the existing onclick event.


    @DavidLozzi
    DavidLozzi.com
    About.me


    Friday, March 30, 2012 4:17 PM
  •  

    Hi Shawn B. Keene,

    I agree with David.

    You can use JavaScript code to prevent users submitting forms multiple times. We have two methods to avoid duplicate submission. The first one is disabling The SUBMIT Button, the second one is using Cookies To Stop Duplicates.

    For more information about how to achieve these methods, please visit the following link:

    http://www.netmechanic.com/news/vol5/html_no16.htm

    Thanks,

    Rock Wang

    Forum Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Rock Wang TechNet Community Support

    Monday, April 2, 2012 6:26 AM
  • Hey Rock,

    I appreciate the reply but unfortunately those methods do not work with SharePoint because the page causes an error if a javascript OnClick attribute is added to the <SharePoint:SaveButton> element.  I will try with JQuery instead today and post back.


    Shawn Keene

    Monday, April 2, 2012 1:06 PM
  • Hi Shawn,

    How is it going?

    Thanks,

    Rock Wang

    Forum Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.



    Rock Wang TechNet Community Support

    Wednesday, April 4, 2012 2:18 AM