Skip Navigation

[Resolved] I am trying to disable the submit button via javascript

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user wanted to disable the submit button on his CRED form using jQuery.

Solution:
To do this please use the code below. Add it to your js section of your CRED form and it should disable the button.

jQuery( document ).ready(function() {
console.log('document is ready');
setTimeout(function() {
         jQuery('.finishprofilebutton').attr("disabled", "disabled") 
    }, 2000);
 
});

Relevant Documentation:

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Shane 6 years, 9 months ago.

Assisted by: Shane.

Author
Posts
#628590

Hi,

I have some javascript code somewhere else on the page, which checks a few things and is supposed to disable the submit button of one of my CRED forms that is being displayed.

jQuery(document).ready does not seem to cut it though, as something else takes the disabled state out. I tried using the javascript panel inside the form in question, add a custom class to the submit button and target it that way, but no dice.

I have no problem executing the javascript code within my CRED form, but right now I had to bind it to mouseenter. This means the button changes states only when the user moves the mouse. I can't have that.

What is the javascript trigger where if I type:

jQuery('.finishprofilebutton').attr("disabled", "disabled");

It stays disabled.

#628785

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Adrian,

Thank you for contacting our support forum.

Would you mind providing me with a link to the page so that I can check on this issue for you ?

Thanks,
Shane

#628910

Hi,

Unfortunately that is part of a locally developed project and behind a login form.

You can however reproduce this easy by creating a CRED form and adding the

jQuery('.finishprofilebutton').attr("disabled", "disabled")

code in the javascript section. What I noticed is that it sets it to disabled, but then the field gets re-enabled. So something is running after document load to ensure that the submit button stays active.

The finishprofilebutton class is a class I added to the Submit button, since the ID is randomly generated for some odd reason.

#628953

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Adrian,

Try setting a delay on the script running. Like this.

jQuery( document ).ready(function() {
console.log('document is ready');
setTimeout(function() {
         jQuery('.finishprofilebutton').attr("disabled", "disabled")
         console.log('button is disabled');

    }, 2000);

});

I tested this and it works for me.

Thanks,
Shane