Skip Navigation

[Resuelto] How to ensure that a file is uploaded before the form is submitted?

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

Problem

How can I make sure that users who submit my Toolset Forms really submit the required data?
I see no way to stop the form from submitting if not all data is completed.

Solution

You can make each field required when you set them up or edit them in Toolset > Custom Fields

As well generic Toolset form Fields can be set as required.

When this is set, a little asterisk will appear next to its label and the form cannot be submitted without any value in them.

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

Asistido por: Beda.

Autor
Mensajes
#625853

Hi,

I have a form where user needs to submit a document. Until the document is uploaded the submit button is not shown,

I found this solution to trigger the display:

$('#submit_create_account').hide();
        $('input:file').change(
            function(){
                if ($(this).val()) {
                    $('input:submit').attr('disabled',false);
                    $('#submit_create_account').show('slow');
                } 
            }
        );

The problem is that the button is shown immediately as the file starts uploading. How can I attach the trigger to the dissapearing of the loading bar, or something else that happen only after the file is fully uploaded?

Thank you.

#625865

You could do it like here, but that is not perfect because the field changes on the fly and CRED Conditional, in this case, seems to fail.
https://toolset.com/forums/topic/disable-submit-button/

What you should do I think is listening to the "value" of the hidden input of your Image field, which usually has an ID like "wpcf-field-slug_hidden".
When that is set (not empty/unset) you can fire the code that then expands a previously hidden div.
enlace oculto

CRED Conditional should do exatly that but somehow on File/Image uploads it fails when AJAX Upload is used, not so when AJAX is disabled.

A possible approach to ensure that the image is uploaded before submit, is to make that field required.

#625933

Brilliant idea, why I didn't think about making the field mandatory, I don't know.

Thanks )