<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Browser Forms</title><link>https://www.infopathdev.com:443/forums/40.aspx</link><description>For browser form specific questions</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>How to validate multiple fields with c# custom code on button click before submitting</title><link>https://www.infopathdev.com:443/forums/thread/98494.aspx</link><pubDate>Tue, 29 Jul 2014 13:23:03 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:98494</guid><dc:creator>RegularMike</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/98494.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=40&amp;PostID=98494</wfw:commentRss><description>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 &amp;quot;Not Empty&amp;quot; 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.

&lt;BLOCKQUOTE&gt;&lt;div&gt;
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
&lt;/div&gt;&lt;/BLOCKQUOTE&gt;

Code:
&lt;BLOCKQUOTE&gt;&lt;div&gt;
    public void CTRL51_Clicked(object sender, ClickedEventArgs e)
    {
    XPathNavigator nav = MainDataSource.CreateNavigator();
    string fieldValue = nav.SelectSingleNode(&amp;quot;/my:myFields/my:name&amp;quot;, NamespaceManager).Value; 

    if (string.IsNullOrEmpty(fieldValue) == true)
    {
    MessageBox.Show(&amp;quot;EMPTY&amp;quot;);
    }
    else
    MessageBox.Show(&amp;quot;Not Empty&amp;quot;);
    }
&lt;/div&gt;&lt;/BLOCKQUOTE&gt;

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&amp;#39;s easier to read there:  
&lt;a href="http://sharepoint.stackexchange.com/questions/109895/how-to-validate-multiple-fields-with-c-custom-code-on-button-click-before-submi" target="_blank" title="http://sharepoint.stackexchange.com/questions/109895/how-to-validate-multiple-fields-with-c-custom-code-on-button-click-before-submi"&gt;StackExchange.com&lt;/a&gt;</description></item></channel></rss>