Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Simon Davis 1 post 21 karma points
    May 29, 2013 @ 06:34
    Simon Davis
    0

    Validation of manditory checkbox lists

    I'm trying to build a form which has a mandatory checkbox list control. I was expecting validation to pass if at least one of the items in the list is selected, however the validation is only passing if the first item in the list is selected.

    I've tried building the form viacode first and form builder in back office, and with different prevalue source types, the validation issue is always the same, only selecting the first item in the list will pass validation.

    Is this the way checkbox list validation is supposed to work?

    I am using:
    Umbraco version: 6.0.5
    Contour Version: 3.0.11

  • Comment author was deleted

    Jun 03, 2013 @ 12:46

    Nope that sounds like a bug :) added to our issue tracker and taking a look now http://our.umbraco.org/forum/umbraco-pro/contour/41350-Validation-of-manditory-checkbox-lists

  • Comment author was deleted

    Jun 03, 2013 @ 13:13

    Hey Simon,

    Any other details to reproduce since I've just tested it and it works like it should (at least 1 option checked)

    Running Contour 3.0.12 

  • Robbie van den Hoven 36 posts 181 karma points
    Jun 13, 2013 @ 14:10
    Robbie van den Hoven
    0

    Have the same problem. Running Contour version 3.0.12 (on Umbraco 4.11.9)

    When you have a checkboxlist with (of course) multiple items and mark the field as mandatory, the javascript validation in the front-end only works on the FIRST item. Not on ANY item.

    So in this case, you just don't want to make a checkboxlist mandatory. But the customer asked for it :-(

  • Comment author was deleted

    Jun 17, 2013 @ 11:18

    @Robbie mind sharing the browser you are trying this in since I'm unable to reproduce

  • Robbie van den Hoven 36 posts 181 karma points
    Jun 17, 2013 @ 11:25
    Robbie van den Hoven
    0

    @Tim, I'm using IE10 an Firefox 21

    I made a testpage with an example http://www.metaglas.nl/informatie/test/

     

  • Comment author was deleted

    Jun 17, 2013 @ 11:30

    @Robbie thanks! 

  • Comment author was deleted

    Jun 17, 2013 @ 11:34

    @Robbie, did you customize the view for the checkboxlist, looks like there is a surrounding div around each checkbox that is causing the issue 

  • Comment author was deleted

    Jun 17, 2013 @ 11:38

    Can you try the following in the /umbraco/plugins/umbracocontour/scripts/frontend/contourform.js file

    find

      $.validator.addMethod('contour_selectonefromlist', function (value, element) {

            var valid = false;

            $("input", $(element).parent()).each(function (i) {

                if ($(this).is(':checked')) { valid = true; }

            });

            return valid;

        });

    and change to

      $.validator.addMethod('contour_selectonefromlist', function (value, element) {

            var valid = false;

            $("input", $(element).closest(".checkboxlist")).each(function (i) {

                if ($(this).is(':checked')) { valid = true; }

            });

            return valid;

        });

  • Comment author was deleted

    Jun 17, 2013 @ 12:03

    Changes are in bold, please let me know if that does the trick then I'll also adjust in the Contour core

  • Robbie van den Hoven 36 posts 181 karma points
    Jun 17, 2013 @ 12:15
    Robbie van den Hoven
    0

    Whoops... I did customize the view, sorry. It works :-)

    Thans for your help.

  • Comment author was deleted

    Jun 17, 2013 @ 12:19

    @Robbie great, thanks for confirming :)

Please Sign in or register to post replies

Write your reply to:

Draft