Make a text field is highlighted if it is not fill in - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Make a text field is highlighted if it is not fill in

Last post 12-15-2020 10:26 AM by Evanz. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 12-14-2020 10:39 AM

    • Evanz
    • Top 200 Contributor
    • Joined on 04-16-2020
    • Posts 56

    Make a text field is highlighted if it is not fill in

    Hi, I am trying to set a "Comments" text field is highlighted when the text is not fill in. It works properly when the form initially created. But When I tried to make edits to the form by leaving the text field empty, it still allows to submit the form with an empty text field. Please see my example form attached as I set the rules/formatting for the submit button, but it does not work properly. Any suggestion is greatly appreciated. Thank you so much!
  • 12-14-2020 11:55 AM In reply to

    Re: Make a text field is highlighted if it is not fill in

    My guess would be that because comments is a rich text field it may not actually be blank. Can you attach one of the XML files you've saved in your library that reproduces this issue?
    Hilary Stoupa

  • 12-14-2020 03:07 PM In reply to

    • Evanz
    • Top 200 Contributor
    • Joined on 04-16-2020
    • Posts 56

    Re: Make a text field is highlighted if it is not fill in

    Enclosed is a copy of my XML file when the rich text field is empty but the form allows to submit without a text successfully. Thanks
  • 12-14-2020 03:09 PM In reply to

    • Evanz
    • Top 200 Contributor
    • Joined on 04-16-2020
    • Posts 56

    Re: Make a text field is highlighted if it is not fill in

    Here are another screenshots.
  • 12-14-2020 03:19 PM In reply to

    Re: Make a text field is highlighted if it is not fill in

    Yup, Comments is not blank - it has HTML tags in it. :) I'll see if can come up with a work-around for you later today.
    Hilary Stoupa

  • 12-14-2020 04:51 PM In reply to

    • Evanz
    • Top 200 Contributor
    • Joined on 04-16-2020
    • Posts 56

    Re: Make a text field is highlighted if it is not fill in

     Sweet. Thank you so much for your workaround on this! :)

  • 12-14-2020 05:04 PM In reply to

    Re: Make a text field is highlighted if it is not fill in

    I haven't figured out anything yet - but I'll take a look in the morning.
    Hilary Stoupa

  • 12-14-2020 06:25 PM In reply to

    • Evanz
    • Top 200 Contributor
    • Joined on 04-16-2020
    • Posts 56

    Re: Make a text field is highlighted if it is not fill in

     Just take your time. No rush. Much appreciated for all your help! :)

  • 12-15-2020 08:01 AM In reply to

    Re: Make a text field is highlighted if it is not fill in

     So - I made a handful of changes here. First, I made sure that your helper "highlight" field gets set to blank at the beginning of the submit rules (I think I left your submit rule disabled in this copy, so check that too). I also set it blank on form load - of course, if you are setting to blank as part of submit, you won't need that, but I wanted your existing test form to work properly.

    I added another field and am setting that to the value of the comment field, removing special carriage return characters (referencing this blog post: http://johnliu.net/blog/2011/11/22/infopath-removing-newline-crlf-using-rules.html). Even then, there was a single char remaining in the test field - I decided to work on the assumption that a single character comment could be considered "blank" - hopefully that's ok. Apparently it is a zero-width space, and I can't figure out how to remove that. :)

    Hilary Stoupa

  • 12-15-2020 10:10 AM In reply to

    • Evanz
    • Top 200 Contributor
    • Joined on 04-16-2020
    • Posts 56

    Re: Make a text field is highlighted if it is not fill in

    Good morning Hilary,

    Thank you so much for all your efforts to make a handful of changes. I really appreciate it. I just tested the form which works properly. :-) Just one thing I realized is that the form still allows to submit the form just to having spaces in the text field. I think a zero-width space is a trick part to remove, but I assume it's rarely happened when the user makes edits and leaves only spaces in the text field.

    One more minor thing: when making edits to the text field, the text field is still highlighted even though I click out of the text field. The highlighted field will only be disappeared when hitting the "Submit" button.  

    Thanks again,

    Have a great day! :-)


  • 12-15-2020 10:19 AM In reply to

    Re: Make a text field is highlighted if it is not fill in

    Yeah - you could always add another translate to the rule that sets test comment - translate out the space character as well. I think on the comment field you should add similar rules to those on submit so that the same logic is applied when the comment field changes.
    Hilary Stoupa

  • 12-15-2020 10:26 AM In reply to

    • Evanz
    • Top 200 Contributor
    • Joined on 04-16-2020
    • Posts 56

    Re: Make a text field is highlighted if it is not fill in

     Got it, thanks!:-)

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