Disable Submit Button after one click with validation?

后端 未结 2 1542
名媛妹妹
名媛妹妹 2020-12-17 06:07

I have a form that is passing data to a cc processing terminal, as well as writing PDF contracts and receipts. There is validation built into the form, and I am trying to ad

相关标签:
2条回答
  • 2020-12-17 06:23

    In your submit button code just add javascript code: <input type="submit" [...] id="btn1" onclick="setTimeout(disableFunction, 1);"> and in Javascript add function:

    function disableFunction() {
        document.getElementById("btn1").disabled = 'true';
    }
    
    0 讨论(0)
  • 2020-12-17 06:33

    You can you if you are using jQuery form validator

    $(document).ready(function () {
        $("#addOfficerForm").submit(function () {
            var total_error = document.querySelectorAll('.error').length;
            if(total_error === 0){
                document.getElementById("checkEditRestriction").disabled = 'true';
            }  
        });
    });
    
    0 讨论(0)
提交回复
热议问题