Tell us what you are trying to do?
Hi. I'm trying to prompt the user see if they are sure they want to submit the form. I'm using the following code on hidden link:
jQuery(document).ready(function($){
$("input[name='form_submit_1']").click(function(event){
event.preventDefault();
if (confirm("Are you sure?")){
$('form#cred_form_9503_1_1').submit();
}
});
});
Please test it. Select any Complaint from the drop down. This form adds a new Complaint Note (Repeatable Group) for a Complaint (Post Type)
But when you click on Submit and then OK from the subsequent pop up I get an error message "Complaints This field is required" when we've already entered a Complaint.
Please help?
Many thanks
Is there any documentation that you are following?
https://toolset.com/forums/topic/are-you-sure-you-want-to-submit/
Is there a similar example that we can see?
What is the link to your site?
hidden link
Hi there,
It is hard to know what is the reason why your JS code is not working and honestly it is outside of our support scope as it is a custom code request.
What I can suggest are the options below:
1- test by adding the code for the Form submit event instead of the click event of the submit button.
2- Test it without the Select2 and see if the method works ok.
3- Use the trigger function and see if it works:
hidden link
If the problem persists one thing that I can suggest:
- On the submit event get the current Select 2 selected items in Javascript using the Select 2 library documentation help and save it in an array.
- After the popup and before trying to trigger the submit event, try to re-input the options to Select 2.
Thank you.
My issue is resolved now. Thank you! I implemented the following code:
$('form#cred_form_8731_1_1').submit(function() {
var c = confirm("Click OK to Submit Note");
return c; //you can just return c because it will be true or false
});