Issue with Javascript in FormMaker
Melissa B created the topic: Issue with Javascript in FormMaker
I need to make sure people are checking an option AND putting in a quantity for a form field. I can't have it be required, because they are allowed to not choose the option at all. The issue is people are entering the quantity (i.e. 1-9, etc) and NOT checking the checkbox which means they don't get charged for the item. So now I need javascript that would make the checkbox active if anything is typed into the quantity boxes. The test link is safariclubpittsburgh.org/registration-fo...17-gala-2-day-event/. Also, I really would prefer, since this is a multi-page form, that it check before the form goes to the next page, not on submit.
The Javascript that is NOT working (to force a checked box if quantity is greater than 0) is:
if (document.form14.wdform_41_element170.checked === false && document.form14.wdform_41_element_quantity17 >0)
{
document.form14.wdform_41_element170.checked=true;
}
Any help would be greatly appreciated. Thank you.
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Agapi G. replied the topic: Issue with Javascript in FormMaker
Hi Melissa!
Firstly please note, that there's the following code written in your custom javascript:
if (((document.form14.wdform_41_element140.checked) && (document.form14.wdform_41_element_quantity14 <=0))) {
alertmsg = alertmsg + "Please enter Quantity" +"\n"; return true;
which is not not exactly correct. It should look like the following instead:
if (((document.form14.wdform_41_element140.checked) && (document.form14.wdform_41_element_quantity14․value <=0))) {
alertmsg = alertmsg + "Please enter Quantity" +"\n"; return true;
But also, our developers are kindly requesting for temporary WordPress admin access to take a look at this. Could you please send the login information? You can use this form to send it privately. Also please mention the URL of this forum thread in your message.
The team will take a look and provide a suggestion.
Thanks! Have a wonderful day!
Kind regards,
Agapi G.
Web-Dorado team
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Melissa B replied the topic: Issue with Javascript in FormMaker
Hi! I sent the credentials in the form.. but quick note, there are TWO separate issues! One from the other open topic and this one..
First, I need to make sure people are checking an option AND putting in a quantity for a form field. I can't have it be required, because they are allowed to not choose the option at all. The issue is people are entering the quantity (i.e. 1-9, etc) and NOT checking the checkbox which means they don't get charged for the item. So now I need javascript that would make the checkbox active if anything is typed into the quantity boxes. The test link is safariclubpittsburgh.org/registration-fo...17-gala-2-day-event/. Also, I really would prefer, since this is a multi-page form, that it check before the form goes to the next page, not on submit.
Second, if people DO check the box, it should alert them to the quantity. Which is what you responded about above. Thanks!
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Melissa B replied the topic: Issue with Javascript in FormMaker
Also, I've created a new test form.. so as not to disrupt anything.. safariclubpittsburgh.org/registration-fo...a-2-day-event-test2/
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Melissa B replied the topic: Issue with Javascript in FormMaker
I did put the above code in and it doesn't work unfortunately. And, I'd rather it execute when the page changes, not on submit.. The first issue is more of a big deal however.. because if the checkbox isn't checked, and they only click quantity, the user thinks they registered and paid, when in reality it isn't sent to paypal. Hope this makes sense. I would imagine this has come up before? Thanks again.
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Melissa B replied the topic: Issue with Javascript in FormMaker
I was able to fix the one issue with this code in the before_load area:
jQuery("#form17 #wdform_41_element_quantity17").change(function() {
// Check input( $( this ).val() ) for validity here
document.form17.wdform_41_element170.checked=true;
}
So, it now checks the checkbox when the quantity is filled in (I will need to put extra checks here, but it works!)
However, I can't seem to get the code to work exactly right when the Next Button is clicked (found something similar in another forum post). It does throw the alert, however, when you click OK, it still goes to the next page, never focusing on the quantity field in the first page to fill in. This is important for when a person clicks the checkbox for the item (Station Signs), but doesn't fill in a quantity.
jQuery("#form17 #page_next_1").click(function() {
// your code
alert("Please enter a quantity");
jQuery("#form17 #wdform_41_element_quantity17").focus();
return true;
} );
The form can be found here:
safariclubpittsburgh.org/registration-fo...17-gala-2-day-event/
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Agapi G. replied the topic: Issue with Javascript in FormMaker
Hi Melissa!
Thank you for providing these the details! I have asked our development team to take a look and provide the correct code for validation upon clicking Next. I will keep you posted with the progress.
Cheers!
Kind regards,
Agapi G.
Web-Dorado team
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Agapi G. replied the topic: Issue with Javascript in FormMaker
Hey Melissa!
I am happy to inform you, that our development team responded with the solution that you will need to go with. They have added the following code to /form-maker/js/main_div_front_end.js file, at the beginning of page_next function:
if(document.form17.wdform_41_element170.checked == true && jQuery("#form17 #wdform_41_element_quantity17").val() == 0 ) {
alert("Please enter a quantity");
return;
}
Also, there were a few incorrect lines on your custom Javascript on Form Options, which were throwing errors. Our development team has fixed these errors for you. Could you please take a look?
Thank you!
Kind regards,
Agapi G.
Web-Dorado team
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Melissa B replied the topic: Issue with Javascript in FormMaker
Thanks for your response. Unfortunately it only works in IE not Chrome ☹ Thanks for fixing the other errors - I was trying lots of things!
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Agapi G. replied the topic: Issue with Javascript in FormMaker
Hello Melissa!
As I mentioned in my email also, the reason the code does not work, is that the elements with ID/class wdform_41_element_quantity17 and wdform_41_element170 have been removed from your form. Note, that you need to replace those with correct IDs of your form fields.
Moreover, if you need to use this for all Single/Multiple choice fields, you will need to write the code for each of those.
Thank you! Have a wonderful day!
Kind regards,
Agapi G.
Web-Dorado team
Please Log in or Create an account to join the conversation.
6 years 6 months ago