Alert

I have 30 questions in a form out of which few are mandatory. If I miss any one of them and go for submit, I can get error message at the end of page (usually before submit button). It is very difficult to scroll up the page and find for the missing ques. Is there any way in where I can get an alert message in the center of the page/near the ques itself ? Please help ....

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to mounikam0001

    Recently, in a similar situation, I tried to just add a sectionLayout to each question. Each section did a check whether any value for that question was entered. This shows a red bar in case the validation fails. Maybe this helps.

  • When you apply validations to both the fields themselves, and within a!formLayout's validations parameter, you will have error messages showing both underneath the field missing data, and at the bottom of the form.  Is that not enough for your requirement?  Note validation pop-ups are not available, but we can show any messages on screen.  

    a!localVariables(
      local!numberOfQuestions: 10,
      local!questions: 1+enumerate(local!numberOfQuestions),
      local!answers: repeat(local!numberOfQuestions,null),
      local!validations: reject(
        fn!isnull,
        a!forEach(
          items: local!answers,
          expression: if(rule!APN_isEmpty(fv!item),concat("Please answer question ",fv!index),null)
        )
      ),
      
      a!formLayout(
        contents: {
          a!forEach(
            items: local!questions,
            expression: a!textField(
              labelPosition: "ADJACENT",
              label: concat("Q",fv!item),
              value: local!answers[fv!index],
              saveInto: local!answers[fv!index],
              required: true
            )
          )
        },
        validations: local!validations,
        buttons: a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: "Submit",
              submit: true
            )
          }
        )
      )
    )

  • Thank you so much Chris. Its clear and worked for me Slight smile