How to Prevent Users from Submitting a Form Twice

后端 未结 16 1014
挽巷
挽巷 2020-12-01 06:59

when user click add button twice, from get submitted twice with same dat

16条回答
  •  星月不相逢
    2020-12-01 07:33

    You can add a class to your form and your submit button and use jquery:

    $(function() {
    
        // prevent the submit button to be pressed twice
        $(".createForm").submit(function() {
            $(this).find('.submit').attr('disabled', true);
            $(this).find('.submit').text('Sending, please wait...');
        });
    })

提交回复
热议问题