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
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 :-(
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
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
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
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
@Robbie mind sharing the browser you are trying this in since I'm unable to reproduce
@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
@Robbie thanks!
Comment author was deleted
@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
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
Changes are in bold, please let me know if that does the trick then I'll also adjust in the Contour core
Whoops... I did customize the view, sorry. It works :-)
Thans for your help.
Comment author was deleted
@Robbie great, thanks for confirming :)
is working on a reply...