Radio Button Validation Rules Being Ignored - InfoPath Dev
in

InfoPath Dev

Radio Button Validation Rules Being Ignored

Last post 02-04-2013 09:04 AM by mnghost. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 02-02-2013 02:36 PM

    • mnghost
    • Not Ranked
      Male
    • Joined on 02-02-2013
    • Minneapolis, MN
    • Posts 3

    Radio Button Validation Rules Being Ignored

    I am designing a form in Infopath 2010 where I have multiple views and a set of radio buttons that I want to be required when the user is on that view. I can't simply set the control to be required since this causes a validation error if I try and submit the form when I am not on the view. Instead, I put a validation rule that is supposed to fire under the condition of:

    MyRadioButton is blank AND
    Current_View = "MyView"  (Current_View is a variable I have set to keep track of what view the user is on)

    The radio buttons even light up red when I look at the view, so I know the conditions are being met correctly. But if I push the submit button without selecting any of the radio buttons it just happily goes on through. I really need it to stop the submit if the user has not selected any of those radio buttons. How can I get this to work?

  • 02-03-2013 07:55 PM In reply to

    Re: Radio Button Validation Rules Being Ignored

    Could you go into a bit more detail about your submit button.  Is it configured as an actual "Submit" action, or is it an ordinary button using a series or rules to do the submit?
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-03-2013 08:40 PM In reply to

    Re: Radio Button Validation Rules Being Ignored

    Hi mnghost,

    What field do you have your validation rule on?  Why not just put a condition on your Submit button as follows:

    • MyRadioButton1 is not blank AND
    • MyRadioButton2 is not blank AND
    • CurrentView is equal to "MyView"

     

    That way the Submit will only go through if all the radio buttons have been answered and the user is currently looking at the MyView view.

    You can even add a rule to display a hidden "error message" section to let the user know why the Submit was not successful. 

     

    That said, here's how I would do things:

     First, set up an error message that will display when the user tries to submit without filling out all the Yes/No radio button questions

    1. Add a TRUE/FALSE field called DisplayErrorMessage and set it's default value to FALSE
    2. Add a section called ErrorMessage and type in something meaningful, like: "ERROR: you cannot submit this form unless you answer all the radio button questions."
    3. Put a condition on the ErrorMessage section to hide the section if DisplayErrorMessage is equal to FALSE
    4. Put a button inside the ErrorMessage section called "Hide Message" and add a button rule to set DisplayErrorMessage to FALSE if the button is clicked

    Next, set up your Submit button to submit if all radio button questions have been answered, and to display the error message if not all of them have been answered

    1. Add an action rule to your Submit button to Submit data only if the following conditions have been met:
      • MyRadioButton1 is not blank AND
      • MyRadioButton2 is not blank AND
      • (add another condition for each additional radio button question) AND
      • CurrentView is equal to "MyView"
    2. For this action rule with conditions above, make sure you check the checkbox at the bottom of the rule pane that says "Don't run remaining rules if the conditions of this rule are met."
    3. Add another rule to your Submit button beneath the above rule. This rule will have no conditions, and will set the field DisplayErrorMessage to TRUE.

     That's it!  Now, when someone clicks the Submit button before filling out all the radio buttons, the rule to Submit data will NOT fire, and instead the rule setting DisplayErrorMessage to TRUE will fire.  Once that field is set to TRUE, the ErrorMessage section will become visible, and the user will see the message.  After the message has been read, the user can click Hide Message to hide the error message section. 

     On the other hand, if the user clicks the Submit button after filling out all of the radio buttons, then the rule to Submit data WILL fire, successfully submitting the form data.  The next rule to set DisplayErrorMessage to TRUE will NOT fire, because you checked the box on the previous rule to not run any remaining rules.

     

    Let me know if you have any questions!

    Jennifer Lindsay
    Qdabra® Software/InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™

  • 02-04-2013 09:04 AM In reply to

    • mnghost
    • Not Ranked
      Male
    • Joined on 02-02-2013
    • Minneapolis, MN
    • Posts 3

    Re: Radio Button Validation Rules Being Ignored

    Thanks for the replies.

    Jimmy, this is just a regular button with a series of actions attached to it, among which is a submit action. I need the button to set a few other field values when it is pressed so was not able to make it a standard Submit button. My other validation rules run with the button press and stop the submit, though. It appears to be just the ones I have attached to the radio buttons.

     Jennifer, I have put a conditional rule on my button so its actions won't fire if the radio button question is not answered and I can take the further steps you suggest to display a message to the user in that event. That sounds like a usable workaround. I have to be honest, though, I'm not real excited about building my own validation messaging functionality into the form when Infopath already claims this functionality and should be working. I guess I'm mainly trying to understand why all my other validations rules work and stop the submit from happening, but the ones I put around the radio buttons do not. Is there something I am missing (an unanswered radio button set does return blank, right?), or are validation rules on radio buttons not meant to work this way?

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