• Resolved MissTT

    (@misstt)


    Hi there I’ve just added interest groups to my signup form – the following code is as per the example given in your help docs to make the selection of at least one interest group checkbox mandatory but it’s not working. The subscription completes without any warning /prompt to select an interest group…

    Code as per this: https://kb.mc4wp.com/interest-groupings-required-field/

    Is there anything wrong with this code below? Web address of the page can be provided privately. Plugin version is Version 4.1.4

    <p>
    <input type=”text” name=”FNAME” placeholder=”Your first name”>
    </p>
    <p>
    <input type=”text” name=”LNAME” placeholder=”Your last name”>
    </p>
    <p>
    <input type=”email” name=”EMAIL” placeholder=”Your email address” required=”required”>
    </p>
    <p>
    <label>Please tell me if you are a Yoga Teacher or a Yoga Student…</label>
    <label><input name=”INTERESTS[da08d4c94b][]” type=”checkbox” value=”1b4a15f029″ checked> <span>Yoga Teachers</span>
    </label>
    <label><input name=”INTERESTS[da08d4c94b][]” type=”checkbox” value=”a65682237f”> <span>Yoga Students</span>
    </label>
    </p>
    <p>
    <input type=”text” name=”MMERGE3″ placeholder=”How did you hear about me?”>
    </p>
    <p>
    <input type=”text” name=”MMERGE4″ placeholder=”Your mobile number”>
    </p>
    <p>To help us distinguish between forms submitted by individuals and those automatically generated by spam software, please enter the question below.{captcha}</p>
    <p>
    <input type=”submit” value=”Sign up” />
    </p>

    <script>
    jQuery(‘.mc4wp-form’).find(‘form’).on(‘submit’, function(evt) {
    var checkboxFields = jQuery(this).find(‘[name^=”INTERESTS”]’);

    if( checkboxFields.length ) {

    // check if at least one field is required
    for(var i=0; i<checkboxFields.length; i++) {
    if( checkboxFields[i].checked ) {
    return true;
    }
    }

    alert(“Please select at least 1 group.”);
    evt.preventDefault;
    return false;
    }

    return true;
    });
    </script>

    Many thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Lap

    (@lapzor)

    Hi,

    Are you sure jQuery is loaded on your website?
    Any error in the browsers JS console?

    While officially we can’t give much support on custom code like this via the www.remarpro.com forum, as always a link to your website where we can see the code fail would still be helpful.

    Thanks,

    Thread Starter MissTT

    (@misstt)

    Hi there, the code is based on Danny’s code – as mentioned above – code as per this just with my specific fields included: https://kb.mc4wp.com/interest-groupings-required-field/

    I’ve set up the code within the forms field in the plugin – do I have to load some other script somewhere too to get this to work?

    It doesn’t mention doing that in the info on that page so I didn’t think there was anything else I needed to do – please let me know what else I need to do in addition to adding the code into the form area within the plugin in order to get the mandatory checkbox checking to work.

    Many thanks in advance.

    Plugin Contributor Lap

    (@lapzor)

    Can you post a link to the form so we can test it and check the browser console for errors?

    Plugin Contributor Lap

    (@lapzor)

    It seems to be some html code that was included within the javascript.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Mandatory Group Interests not working’ is closed to new replies.