Checkbox field validation in a repeating table - InfoPath Dev
in

InfoPath Dev

Checkbox field validation in a repeating table

Last post 08-08-2011 12:45 PM by ynygma. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-24-2010 01:33 AM

    • dogah
    • Not Ranked
    • Joined on 03-24-2010
    • Posts 2

    Checkbox field validation in a repeating table

    Hello;

    I have a browser-enabled form which has a repeating table in it.

    My problem is: how can i validate that at least one of the checkboxes  is selected and prevent the form to be submitted if none is selected.

    I'd appreciate any help.Thank you

    Doga 

  • 03-24-2010 08:39 AM In reply to

    • dogah
    • Not Ranked
    • Joined on 03-24-2010
    • Posts 2

    Re: Checkbox field validation in a repeating table

    I had a different solution.

    In changed event of the checkbox i controlled if the value is true, then set a value in the xml which i control when submitting the form.It works fine.Remember to set "always"  ıf the postback options of the checkbox

  • 06-07-2011 11:41 PM In reply to

    Re: Checkbox field validation in a repeating table

     Please check if this helps to you

    var isValid  ="0";

    $("[id$='tbl']  :checked").each(function () {
                    isValid = "1";
                    return true;
                });

                if (isValid == "0") {
                    alert('Please select at least one  Value');
                    return false;
                }

     

    <table id ="tbl" >

    <tr><td>chk1<td></tr>

    <tr><td>chk2<td></tr>

    </table>

  • 06-08-2011 04:07 AM In reply to

    • Skarn
    • Top 50 Contributor
      Male
    • Joined on 04-20-2008
    • Australia
    • Posts 198

    Re: Checkbox field validation in a repeating table

    * You could do this with jScript - it might even be easier than the following method, which doesn't require rules.

    When I've had multiple check boxes - and at least one must be checked, I've used a counter field.

    So you have 3 chk box fields my: chkBox1, my: chkBox2, my: chkBox3. You also create a field to store a 'counter' my:chkCount

    On each chkBox field I put two rules.

    if chkBox = true then my:chkCount = my:chkCount + 1

    if chkBox = false then my:chkCount = my:chkCount - 1

    This means that whenever at least ONE check box is ticked, my:chkCount will be greater than 0 and if none are ticked then my:chkCount = 0

    Then on  each chkBox validation rules I say that my:chkCount must be > 0. So all chkBoxes now show up outlined in Red until at least one checked.

    I currently have Infopath uninstalled - if you still don't understand, I'll be back tomorrow with an example to attach.

     

  • 08-08-2011 12:45 PM In reply to

    Re: Checkbox field validation in a repeating table

    Eureka!  (which is also a great show on scfi;)

     

    Anyway, thank you thank you!

    I went about it a little different but you spurred the idea for me with the chkCount hidden field.  What I did different was to due my validation on the Submit button to check to see if chkCount > 0 and that worked perfectly:)

     Thank you,
    Ynygma

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.