Hi, I'm trying to put check boxes with validations ,for that user

Hi,
I'm trying to put check boxes with validations ,for that user need to select atleast one box. I wrote the code for 2 option check boxes and required attribute mentioned in the second checkbox. How can i get the validation on top of the 2 choices(Near Select all that apply) instead at bottom. Please find the attachments for reference. Thanks in Advance.

test.docx

OriginalPostID-168726

OriginalPostID-168726

  Discussion posts and replies are publicly visible

  • 0
    Certified Associate Developer
    the question is not that clear to me.. but what i understood is: You need the validation(*) for all items instead for 2nd checkbox. infact that is the default behaviour of SAIL.

    =load(
    local!userAgreed,
    a!formLayout(
    firstColumnContents: {
    a!checkboxField(
    label: "select all that apply",
    choiceLabels: {"c1","c2"},
    choiceValues: {1,2},
    value: local!userAgreed,
    saveInto: local!userAgreed,
    required: true,
    requiredMessage: "You must check atleast one!"
    )
    },
    buttons: a!buttonLayout(
    primaryButtons: a!buttonWidgetSubmit(
    label:"Submit"
    )
    )
    )
    )
  • Thanks Rajivfor response , let me explain bit clear. I'm using below code for selecting at least 1 checkbox else throw an validation error.

                                            Select all that apply,
    a!checkboxField(
    label: "",
    labelPosition: "ADJACENT",
    choiceLabels: {option A},
    choiceValues: {"Y"},
    value: something,
    saveInto: something
    ),
    a!checkboxField(
    label: "",
    labelPosition: "ADJACENT",
    choiceLabels: {Option B},
    choiceValues: {"Y"},
    value: something,
    saveInto: somehting,
                                             required: and(                                        
    rule!APN_isBlank(ri!coreMeasure.NotCollectedByProvider),
    rule!APN_isBlank(ri!coreMeasure.NotCollectedOther)
    )
    )
                                            
                                            For the above code , i'm getting * symbol on other but how can i get that near select all that apply so that user can able to understand that any 1 need to be selected not just other. Hope you understand now.
  • I would put a textField above with blank value, read only, that is only required if none of the checkbox items are selected:

    =load(
    local!checkValA: null,
    local!checkValB: null,
    a!formLayout(
    firstColumnContents: {
    a!textField(
    label: "Select All That Apply",
    value: "",
    readOnly: true,
    required: and(rule!APN_isBlank(local!checkValA),rule!APN_isBlank(local!checkValB))
    ),
    a!checkboxField(
    label: "",
    labelPosition: "ADJACENT",
    choiceLabels: {"OptionA"},
    choiceValues: {"Y"},
    value: local!checkValA,
    saveInto: local!checkValA
    ),
    a!checkboxField(
    label: "",
    labelPosition: "ADJACENT",
    choiceLabels: {"OptionB"},
    choiceValues: {"Y"},
    value: local!checkValB,
    saveInto: local!checkValB/
    )
    },
    secondColumnContents: {},
    buttons: a!buttonLayout(
    primaryButtons: {
    a!buttonWidgetSubmit(
    label: "Submit"
    )
    },
    secondaryButtons: {
    a!buttonWidgetSubmit(
    label: "Cancel",
    skipValidation: true
    )
    }
    )
    )
    )
  • 0
    Certified Associate Developer
    =load(
    local!x,local!y,
    a!formLayout(
    firstColumnContents: {
    a!textField(
    label: "Select all that apply",
    labelPosition: "ABOVE",
    saveInto: {},
    required:true(),
    readOnly:true(),
    value:if(and(isnull(local!x),isnull(local!y)),""," "),
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!checkboxField(
    labelPosition: "ADJACENT",
    choiceLabels: {"option A"},
    choiceValues: {"X"},
    value:local!x,
    saveInto: local!x
    ),
    a!checkboxField(
    labelPosition: "ADJACENT",
    choiceLabels: {"option B"},
    choiceValues: {"Y"},
    value: local!y,
    saveInto: local!y
    )
    },
    buttons: a!buttonLayout(
    primaryButtons: {
    a!buttonWidgetSubmit(
    label: "Submit"
    )
    }
    ),
    validations: {}
    )
    )
  • Thanks much Steward and Rajiv , i'll work on your suggestions. I appreciate!
  • No problem. Note my typo on line 26, remove the "/" at the end.