خرید بک لینک

Vote count: 0

*This was previously marked as a duplicate in error. As you can see, I've already resolved the issue of validation that at least one checkbox has been checked. Please read to the end, the issue is integration with WordPress (and possibly Divi theme). The code breaks upon insertion into the theme.


I've been searching for a way to validate that "at least one checkbox has been checked" for a mailchimp form, with regards to forcing the user to select at least one (but potentially more than one, which radio buttons do not allow) and finally pieced together what seems to be a working solution on jsfiddle: http://jsfiddle.net/m68yhh5b/

jQuery(document).ready(function ($) {

jQuery('#mc-embedded-subscribe-form').validate({
    rules: {
        'group[]': {
            required: true
        },
    },

    errorPlacement: function (error, element) {

        // name attrib of the field
    var n = element.attr("name");

    if (n == "FNAME")
        element.attr("placeholder", "Please enter your first name");
    else if (n == "EMAIL")
        element.attr("placeholder", "Please enter your email address"); 
    else if (n == "group[]")
        jQuery('.errmsg').html("Please select at least one:")
    },

    submitHandler: function (form) { 

        form.submit();
    }
}); 
});

However, when I attempt to load this onto my WordPress site (Divi theme installed) it's not working.

There are no errors - it's almost as though the scripts aren't even there (but they are when I view the page source). I'm not very experienced with programming so I'm not really sure what's going on, but I'm hoping someone can let me know why this may not be working.

I'm using the Divi "code" module to embed the form, and placing the surrounding javascript in that same module. I did upload the jquery.validate and additional-methods scripts to my server, and called them from within this same module using script tags.

Any ideas?

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 خرداد 1395 ساعت: 5:49

صفحه بندی