Skip Navigation

[Resolved] Are you sure you want to submit?

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

Problem:

The issue here is that the user wanted to prevent their Toolset form from being submitted unless the user clicks yes to a Popup question after clicking submit.

Solution:

This can be done by using the JS below.

jQuery(document).ready(function(){
  $("input[name='form_submit_1']").click(function(event){
    event.preventDefault();
    if (confirm("Are you sure you want to report this offer as broken?")){
        jQuery('form#cred_form_28499_1').submit();
  }
  });
});

This will prompt the user with a question and only submit the form once the user answers yes to the question.
This support ticket is created 5 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 12 replies, has 2 voices.

Last updated by matthewL-7 5 years, 9 months ago.

Assisted by: Shane.

Author
Posts
#1194368

Hi,

Is it possible to enable an are you sure you want to submit message on a CRED form?

I saw this article and tried this javascript but it didn't seem to work:
https://toolset.com/forums/topic/are-you-sure-on-cred-form-save/

Really want to be able to do this but can't figure out a way?

Thanks for any help you can provide! 🙂

#1194461

Shane
Supporter

Languages: English (English )

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

Hi Matthew,

Thank you for contacting our support forum.

Would you mind sending me a link to the page where you want this to be implemented?

Thanks,
Shane

#1194732

Hi Shane,

Sure no problem see for example this page:

hidden link

If you look for the link that says report as broken and click this, this submits a form but I would like it to show a pop up message saying are you sure before it submits the form.

Thanks.

#1195436

Shane
Supporter

Languages: English (English )

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

Hi Matthew,

Add this jQuery to the js section of your form and it should help

 jQuery("input[name='form_submit_1']").click(function(){
      if (confirm("Click OK to continue?")){
         jQuery('form#cred_form_28499_1').submit();
      }
   });

Please let me know if this helps.
Thanks,
Shane

#1195460

Hi Shane,

Thanks for your help - the pop up appears however regardless of what the user clicks ok or cancel it still submits the form.

Obviously if they click cancel it should not still submit the form.

Any ideas?

#1195468

Shane
Supporter

Languages: English (English )

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

Hi Matthew,

Could you try this one instead?

jQuery("input[name='form_submit_1']").click(function(){
     if (confirm("Click OK to continue?")){
        jQuery('form#cred_form_28499_1').submit();
     }else{jQuery("input[name='form_submit_1']").preventDefault()}
  });

I cancelled the default option if yes isn't clicked.

Thanks,
Shane

#1195473

Hmm still the same issue Shane? :-/

#1195479

Shane
Supporter

Languages: English (English )

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

Hi Matthew,

Would you mind allowing me to have admin access so that I can perform proper testing on this one for you ?

Thanks,
Shane

#1196285

Shane
Supporter

Languages: English (English )

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

Hi Matthew,

I've fixed this for you and should work as intended now .

The correct code is

jQuery(document).ready(function(){
  $("input[name='form_submit_1']").click(function(event){
    event.preventDefault();
    if (confirm("Are you sure you want to report this offer as broken?")){
        jQuery('form#cred_form_28499_1').submit();
  }
  });
});

Please let me know if everything is ok now.

Thanks,
Shane

#1196292

Hi Shane,

That is great thanks! It is working perfectly now 🙂

Cheers.

#1196293

Shane
Supporter

Languages: English (English )

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

Hi Matthew,

Awesome Happy I was able to resolve this for you.

You can go ahead and mark this one as resolved.

Thanks,
Shane

#1196311

Shane
Supporter

Languages: English (English )

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

If there are any other issues please don't hesitate to contact us again.

#1196324

My issue is resolved now. Thank you!