0

I am customizing a wordpress theme. When the user clicks the submit button it should be disabled.

I was not able to figure out how to do it. Here is the code. Could someone please tell me how to do this.

jQuery('.modal-content').dialog({
                autoOpen: false, 
                title: 'Confirm your Res', 
                resizable: false,
                height: 175,
                width: 300, 
                modal: true, 
                buttons: {
                    Submit: function() {                                    

                        jQuery('form[name="booking-form"]').get(0).submit();
                    }, 
                    Cancel: function() {
                        jQuery(this).dialog("close");

                    }
                }
            });

5 Answers 5

2

I'm using this code on my website.

$("#dialog-alert").dialog({
    autoOpen: false,
    width: 320,
    modal: true,
    buttons: {
        Submit: function (e) {
            // Disable button
            $(e.target).attr("disabled", true);

            // Write your code here

            // Enable button
            $(e.target).removeAttr("disabled");
        }
    },
});
Sign up to request clarification or add additional context in comments.

Comments

1
$('.submit').click(function(event) {
 event.preventDefault();
});

or see

Disable submit button on form submit

Comments

0

This will "disable" the button once the form is submitted:

jQuery('.modal-content').dialog({
            autoOpen: false, 
            title: 'Confirm your Res', 
            resizable: false,
            height: 175,
            width: 300, 
            modal: true, 
            buttons: {
                Submit: function() {                                    
                    jQuery('form[name="booking-form"]').get(0).submit($("form[name='booking-form'] input[type=submit]").attr("disabled", "disabled"));
                }, 
                Cancel: function() {
                    jQuery(this).dialog("close");

                }
            }
        });

Comments

0

This will disable all the buttons on the popup once the user clicks the OK button.

  $(popupHtml).dialog({
    title: "Add an Absence",
    width: 750,
    height: 300,
    buttons: {
        "Ok": function () {
            $(this).parent().find('button[role=button]').attr('disabled', 'disabled');
}

}

Comments

0

you can also include the disabled styling to make them look disabled

buttons: {
    "Ok": function () {
        $(this).parent().find('button[role=button]').attr('disabled', 'disabled').addClass('ui-state-disabled');

Alternatively you could create your own class with a background "loading" animation for example.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.