Skip Navigation

[Resuelto] Disable submit button?

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
Can I disable or hide the Submit button in a CRED form by conditions?

Solution:
Yes, you use CRED Conditional Fields.

Let me put a code example below with 2 fields.
If none is filled, you cannot submit the form and a message will tell you what is wrong.
If at least one field is filled, you may submit the form.

[cred_show_group if="($(first-field) eq  '' ) AND ($(second-field) eq  '' )"  mode='fade-slide']
  You need to fill at least... xy fileds... to submit the form
[/cred_show_group]
[cred_show_group if="($(first-field) ne  '' ) OR ($(second-field) ne  '' )"  mode='fade-slide']
  [cred_field field='form_submit' value='Submit' urlparam='' class='btn btn-primary btn-lg' output='bootstrap']
[/cred_show_group]

With this, if no field is filled, the Form cannot be submitted and a message is displayed.
If at least one field is filled, you can submit the form and the message disappears.

And, the best is, this all happens before the user even needs to submit the form.

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-display-for-form-inputs/

This support ticket is created hace 6 años, 10 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por Valeriia hace 6 años, 10 meses.

Asistido por: Beda.

Autor
Mensajes
#608187

Hi,

I'm struggling to disable the submit button.

jQuery(document).on('cred_form_ready', function(){
    var $ = jQuery;
    $('input[type="submit"]').prop('disabled', true);
});

Does not work.

Please advise. Thank you.

#608235

Why do you want to disable it?

There can be 2 reasons:
1. You want to avoid the user to press it before certain data is added to the form
2. You want to avoid the user to press it twice or more times in very short time - provoking several mixed posts to be created.

#2 is solved by updating CRED to the latest versions, and #1 can be solved using a CRED Conditional instead, where you hide the button until the condition is met.

Would that help you to achieve your goal?

Also, "ready" should be working on CRED forms as well, in past you needed "cred_form_ready", but it should be possible to use "ready" as well.

If not, we can look into the custom JS Solution you try to use.

#609195

Hi Beda,

You are right, I want to avoid the user pressing it before he added the data.

Thanks for the reply, I guess I'll go with the conditions.