locked
Infopath form Validation RRS feed

  • Question

  • I have a form with several views. In one view I have option button and text boxes and they all need to be filled by the user. In another view I have option button and text boxes. When one view is selected by the user and submitted it also wants the other view to be filled by the user because I have made all field cannot be blank. How do I resolve this issue?

     

    Thank you




    • Edited by ChitraSaha Wednesday, January 18, 2012 6:52 PM
    Wednesday, January 18, 2012 5:58 PM

All replies

  • In one form I have a view which has option button and text boxes. How can I validate the buttons and text boxes so that the user has to 

    select all buttons before the form is submitted.

     




    • Edited by ChitraSaha Wednesday, January 18, 2012 3:35 AM
    • Merged by Clayton Cobb Thursday, January 19, 2012 8:54 AM Same question with different details
    Tuesday, January 17, 2012 10:14 PM
  • Hi,

    This is what I usually do, maybe you could try it:

    Instead of setting the fields to be mandatory, put rules on your submit button to check wether the option buttons are marked or not.

    I have forms with lots of views, each view has it's own submit button with rules to make sure that everything in that view is filled out.

     

    /niax

    http://marriedtosharepoint.com

    Wednesday, January 18, 2012 7:51 PM
  • By not making them required if they're not required, right?  If they aren't truly required ALWAYS, then they should not be set to be required always.  If you only want fields to be required SOMETIMES, then you make them conditionally required by using data validation rules.  A data validation rule would say "If field1 is not blank AND field2 is blank."  In this case, field2 only becomes required when field1 is not blank, but if field1 is blank, then it doesn't matter.  This is how you make things conditionally required.

    In your case, if the user is allowed to switch view on their own with the view selector (not a good idea), then you don't have much choice.  However, if you are using buttons in the form to let the user switch views, then your view buttons should all have actions in them that set a hidden field to a value that references the related view.  For instance, if the user clicks the button for view 2, then you set a hidden field to the value of 2.  Next, you'd make all the "required" fields on that view conditionally required ONLY when the hidden field is equal to 2.  Rinse and repeat for all views.

    Niax also mentioned another good technique, which I think you should do in combination with what I wrote above.  You should always conditionally format your submit button so that it can't be clicked unless all requirements of the form are met.


    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    Thursday, January 19, 2012 3:27 AM
  • Hi ChitraSaha,

    We can add Validation rule to the option buttons, then if the validation failed, InfoPath will stop the form to submit.

    Here is an example:
    I have a group of option button (field1) with 3 buttons, return values are 1, 2, 3.
    Then create rules for the option button > Validation rule > Add condition: field1 is not equal to "1", and field1 is not equal to "2", and field1 is not equal to "3", Show ScreenTip: make select one choice here.

    Let me know if you have any question.

    Best regards,
    Emir

     


    Emir Liu

    TechNet Community Support

    Thursday, January 19, 2012 4:01 AM
  • I have added the following rule on the button to submit data and switch view but how to I add the rule to check if the option buttons are marked or not. Tried adding Rule 2 where option field is not blank but it not working.
    Rule 1 works great and I can submit and switch view but do not have the validation part working yet. I need all option and text boxes in that view to be checked before the form is submitted.
    • Edited by ChitraSaha Thursday, January 19, 2012 8:32 PM
    Thursday, January 19, 2012 6:04 PM
  • I have added the following rule on the button to submit data and switch view but how to I add the rule to check if the option buttons are marked or not. Tried adding Rule 2 where option field is not blank but it not working.
    Rule 1 works great and I can submit and switch view but do not have the validation part working yet. I need all option and text boxes in that view to be checked before the form is submitted.
    I gave you that answer in detail.
    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    Friday, January 20, 2012 6:52 AM
  • Hi Clayton,

    Thanks for your support and I want to describe what I have tried thus far. In my form I need all option buttons to be clicked by the user before they submit.Option button properties for TravelA1, Data type True/False value=1 and for the other set Datatype True/False and value=True

    1. I have tried creating validation rule on the option button and it did not work before submitting the form, so I could submit the form and did not ask me that TravelA1 and TravelB1 were required.

    2. I have also tried created rules on the submit button where rule 1 submits data and changes view and rule 2 checks for the field if it is blank. And this one did not work either that means I can submit data without any error, do not know what I am missing.

    I have also tried  checking the field property cannot be blank and when I submit it checks for the validation but since it is a view it causes issue. I also need to add validation in other view and then I cannot submit form until all the views are complete so do not know how to get around this issue either.

     

    Thanks

    Chitra




    • Edited by ChitraSaha Friday, January 20, 2012 2:50 PM
    Friday, January 20, 2012 2:28 PM
  • Hi,

    Ok, let's see if I got this right.

    In my world TravelA, which has two different radio buttons to choose from, is ONE control with two choises.

    Same with TravelB.

    Create a new field called Error.

    The submit button should check if TravelA OR TravelB is blank and if so set Error to value 1 AND stop running the remaing rules (the check box at the end).

    Ok, so now we know if they made a choise for both or not.

    Because it's a Web form you don't have the choise to show a message as an action when Error is equal to 1.

    So we have to do it in some other way.

    What I use to do is to add a Section to the form and write my message inside. To this Section I add a Formating rule that says to hide this section if Error is blank.

    And as Clayton suggested, you could also add some rules and stuff to disable the change view buttons until all options are selected in that view.

    Does this help you in any way?

    /niax

    http://marriedtosharepoint.com

    Friday, January 20, 2012 11:09 PM
  • The validation works if you do it right.  In your screenshot, you have a warning saying you haven't done it right - there is no ScreenTip message.  You may have fixed that, but the form WILL NOT let you submit if validation fails.  If validation DOESN'T FAIL, then that's because the condition was not met.  If the condition was not met, then you didn't build it correctly.

    Do not use "cannot be blank."  I explained that.

    You can't use action rules on the submit button - that doesn't make sense.

    THis is easy stuff - you just have to get the logic right.


    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    Saturday, January 21, 2012 7:24 AM
  • Hi Niax,

    I am a newbie to both infopath form and sharepoint 2010, but I do follow your above statement and I have tried to create a rule from what I understand reading your suggestions, I have also got some help from S.Y.M cookbook Infopath2010.

    Added Rule on Form Submit, allow users to submit the form and add Perform custom action using Rules

    Rule on Form Submit.

     

    Also added another rule if Error = False and isSectionVisible=1

    Added a section isSectionvisible will add this is next section

     

     

    Tuesday, January 24, 2012 8:11 PM
  • Added a section isSectionVisible:

    and I had the submit button rules

    however I could not enable error message in the forms. Not quiet sure where I could have gone wrong!!

    Tuesday, January 24, 2012 8:14 PM
  • First of all I believe the question is: Set validation on the button that goes to the next view, not the submit.

    I have the same thing to figure out.  On the "button" the validation option first of all is not available. 
    I have a form made up of numerous "views" each one really (to the user) being different forms, all submitting to the same list.

    I want to provide the user a seamless one form (17 of them) via views and the "Next Form" button, but do not want them to be able to go to the next form (actually a view) without filling out the required fields on the field.

    Same issue as the person asking the question here.  Set the rules on the fields to no avail because it is not a submit button, cannot set the rule on the button.  When I figure it out (if possible) will list the answer.  But I totally understand the delimia


    Frances Garland
    • Proposed as answer by CrjangelFG Thursday, January 26, 2012 2:12 PM
    • Unproposed as answer by Clayton Cobb Thursday, January 26, 2012 3:09 PM
    Thursday, January 26, 2012 2:08 PM
  • Ok here is the answer I came up with and it is very simple.

    On the "Switch view" button or whatever you called in in my case "Next Form" set a formatting rule that states that if the field that you want the user to fill out (required) is blank or not what you want (True if a check box to indicate they signed the form whatever) Disable the control!

    Then they will not be able to switch views or go to the next "View or Form" without filling in the required fields.  Hope that helps.


    Frances Garland
    Thursday, January 26, 2012 2:15 PM
  • Hi Frances,

    Thank you for the brilliant idea that is working without using any code but is a way to also create a text stating that all fields need to be completed

    before submitting the form.

    Thursday, January 26, 2012 5:29 PM
  • Hi ChitraSaha,

    I have done a revision of how to do a validation and you can read all about it on my blog post here.

    I really hope this is good enough to be an answer to your question.

     

    /Niax

    http://marriedtosharepoint.com

    Sunday, January 29, 2012 8:50 PM