Why doesn't my form post when I disable the submit button to prevent double clicking?

后端 未结 10 1327
广开言路
广开言路 2020-12-31 19:06

Like every other web developer on the planet, I have an issue with users double clicking the submit button on my forms. My understanding is that the conventional way to han

10条回答
  •  死守一世寂寞
    2020-12-31 19:41

    UseSubmitBehavior="false" converts submit button to normal button (). If you don't want this to happen, you can hide submit button and immediately insert disabled button on its place. Because this happens so quickly it will look as button becoming disabled to user. Details are at the blog of Josh Stodola.

    Code example (jQuery):

    $("#<%= btnSubmit.ClientID %>").click(function()
    {
      $(this)
        .hide()
        .after('');
    });
    

提交回复
热议问题