How to validate multiple fields with c# custom code on button click before submitting - InfoPath Dev
in

InfoPath Dev

How to validate multiple fields with c# custom code on button click before submitting

Last post 07-29-2014 06:23 AM by RegularMike. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 07-29-2014 06:23 AM

    How to validate multiple fields with c# custom code on button click before submitting

    My main goal here is to pop up a validation box that lists which fields have not been populated(still empty) before allowing the user to submit. I know you can use the method built into InfoPath but some of my fields are People Pickers and that option is not available. Here is what I have been playing around with but am unable to get it to validate the field to be empty or not. It always ends up showing "Not Empty" even if I set a default value or enter a value in the field before pressing the button. This is just a test field, but I have over 10 fields I would like to compare.
    Outline: -Get field value -Compare field to see if blank -Pop-up box with field name if blank -Do not allow submission if field is blank
    Code:
    public void CTRL51_Clicked(object sender, ClickedEventArgs e) { XPathNavigator nav = MainDataSource.CreateNavigator(); string fieldValue = nav.SelectSingleNode("/my:myFields/my:name", NamespaceManager).Value; if (string.IsNullOrEmpty(fieldValue) == true) { MessageBox.Show("EMPTY"); } else MessageBox.Show("Not Empty"); }
    Any help would be appreciated. I am having trouble making this post read-able. I do not see any tools when posting this to change the spacing between lines. Here is a link to the same issue on another site if it's easier to read there: StackExchange.com
Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.