Skip Navigation

[Resolved] Disabling submit button

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

Problem:
Disabling submit button on CRED forms

Solution:
To disable the submit button on your form, you should add following code to your Form's JS section:

jQuery(document).ready(function($) {
     submit_id = jQuery("input[type='submit']").attr('id');
     document.getElementById(submit_id).disabled  = true;
 });

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/disabling-submit-button/#post-1109275

Relevant Documentation:

This support ticket is created 6 years, 2 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.

Our next available supporter will start replying to tickets in about 1.81 hours from now. Thank you for your understanding.

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

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by mayurJ 6 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1109096

Tell us what you are trying to do?
===========================
I want to disable the submit button on page load by default. And then enabling it, ONLY if the user has Javascript enabled. I need Javascript to ensure that the password is of a minimum strength, and that the username is not empty.

Normally, for the input submit button on a regular form I would simply use

<input type="submit" value="Submit" id="submitBtn" disabled />

Can I pass the disabled parameter to [cred_field] somehow?

Or alternatively, should I manually output the rendered input button instead like this:

<input type="submit" id="cred_user_form_635_1-submit-1-1537133629" disabled>

Is it OK to hard-code the ID?

Is there any documentation that you are following?
==========================================
Not really

Is there a similar example that we can see?
===================================
I would like to use solution described here:
https://stackoverflow.com/questions/1964758/disable-submit-button-when-javascript-is-disabled

What is the link to your site?
=======================
hidden link

Side question: If I use the cred_save_data hook, and I redirect the user back to the signup form on form validation, will the form data be saved?

UPDATE regarding side question: Looks like the user has to re-enter the form data...

#1109275

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - to disable the submit button on your form, you should add following code to your Form's JS section:

jQuery(document).ready(function($) {
     submit_id = jQuery("input[type='submit']").attr('id');
     document.getElementById(submit_id).disabled  = true;
 });

Regarding your other question, could you please open a new ticket.

#1111247

Totally irrelevant feedback and wasn't helpful. I know how to disable a button via JS already. I have done post-processing on the form inputs to ensure some values are used so this is not an issue anymore.