locked
Validate Checkboxes in Repeating table RRS feed

  • Question

  • Hi Guys,

    I have a strange issue this time, I have to validate the checkboxes under the repeating table, each row has a dynamically populated check box and I need to validate that all the checkboxes from each row should be checked on Form submit event.

    Any help would be much appreciated.

    Thanks


    Amar Deep Singh

    Friday, September 27, 2013 3:06 AM

Answers

All replies

  • Hello,

    If you want keep all checkboxes checked then keep checkbox column disable on form load so no one can uncheck any.

    Another way is, you can add one select all checkbox control so if any of check box is uncheck then uncheck all and if any of them is check then check all.

    http://www.bizsupportonline.net/infopath2010/how-to-check-all-check-boxes-repeating-table-infopath-2010.htm

    Does it works for you

    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, September 27, 2013 5:12 AM
    Moderator
  • You can validation using jquery validator like this:

    $.validator.addMethod('cb_selectone', function (value, element) {
    if (debug) {
    $.jGrowl("Adding Validation");
    }
    var chkGroup = $("input[id^=MainContent_CBContext]");
    if (chkGroup.length > 0) {
    for (var i = 0; i < chkGroup.length; i++) {
    if ($(chkGroup[i]).attr('checked')) {
    if (debug) {
    // alert(i + $(chkGroup[i]).val());
    $.jGrowl("Running loop " + i + " = " + $(chkGroup[i]).val());
    }
    return true;
    }
    }
    return false;
    }
    return false;
    }, 'Please select at least one option');

    Tarek Yehia
    Blog:http://sharepointserver-2007.blogspot.com/


    Tarek Yehia

    Friday, September 27, 2013 5:35 AM
  • Thanks for your replies, but i cannot make the checkboxes disabled or add one select all checkbox, the only purpose to notify the user to select all checkboxes because he is auditing something and submitting the forms. If he left any of the checkbox un-checked then he missed something to audit, then a message box appears during submission of the form.

    Thanks


    Amar Deep Singh

    Friday, September 27, 2013 6:48 AM
  • ok. Then use expression rule like:

    count(current()/preceding-sibling::my:group1/my:field1[. = "false"]) == 0 or count(current()/following-sibling::my:group1/my:field1[. = "false"]) = 0

    Refer this:

    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/61834b16-368a-46b4-9e4f-47ee5b5c4721/validating-a-checkbox-in-repeating-table


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, September 27, 2013 6:58 AM
    Moderator