开发者

ASP.NET MVC button multiple clicks

ok i have a form on which i have some validation through dataannotation which is client side as well as server side validation like some field already exists. i have no javascript validations on the page. now my problem is that what should i do if the user presses开发者_JAVA百科 the save button multiple times (he keeps pressing the button for 15 times,in my case the page stays there with field already exist message at the top ) . what do u guys do for that?

what i have done (this works fine in firefox but not in ie) it disable the button no matter what just after click in ie

  $(document).ready(function () {
     $("#btn").submit(function () {
         $('#btn').attr('disabled', 'disabled');
     });
 });


Put an overlay above the whole page. The overlay prevents the user from clicking twice and gives some feedback. The blockUI plugin does this very well.

EDIT:

$(document).ready(function () {
 $("#btn").click(function () {
     $('#btn').attr('disabled', 'true'); // Disable the button if you like
     $.blockUI(); // Blocking the page with a standard message.
 });
});


try using .live or you could hide the button after it is pressed.

$(document).ready(function () {
     $("#btn").live("click", function () {
         $('#btn').attr('disabled', 'disabled');
//or
         $('#btn').hide();
     });
 });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜