I have a form with a lot of validation based on what item is selected from a dropdown. An issue I just discovered was that even though I have the NotValidIfNullOrEmpty the data can still accepted (Saved) if a space is "entered" - I go into the field and physically enter a space. What is the best way to handle that problem? I tried adding on to the statement in the attached graphic: OR IF Field = " " THEN it would be invalid, but I was able to save the item.
Update 1: I am now trying to work with the Regular Expression. I am getting closer but still not the desired output: I entered this expression:
It works to some extent BUT I can still enter a blank space and the form saves
Thank you so much!
But, only in an instance with one item being validated. Once I tasted on all of the items it went back to the same behavior. A space in any of them allowed the form to still be saved as if data was entered.
I tested various combos of filled-in vs blank space vs no data entered and the outcomes are inconsistent. Sometimes the NO BLANK space works but then in another field it allows it.
What I had to do: Since the solution offered seems to work partially I spent time trying to figure out what accounted for the "inconsistencies". What worked in the end was deleting ALL the validation rules that used this formula an re building them. Going through and making edits seemed to somehow muddy the water and I ended up getting more erroneous outputs with each try. Staring fresh and one-by-one seems to have solved the issue.
UPDATE: The solution was a partial fix. It gave unexpected results in some of the choices. The validation was failing at some points. Once I removed the trim for re-testing the validation works as expected - assuming no-one enters a blank space. With the TRIM the validation itself was failing on several of the options. Perhaps I have too many variables to properly use the TRIM in this instance?
have you noticed any pattern when it works and when not?
if you get incosistent results check developer console for any errors. if there are reported any you will have to fix them all first.
try to add set of calculated value controls to evaluate each (sub)expression of your above formula separately.
ie. single formulas will look like:
whole expression on the right of && operator
post a screenshot how do they all evaluate for a case when you are able to submit a form but shouldn't be able to.
I will try making the change after QA test. I sent it back to them without the TRIM to set the validation. I did not make them aware of what I did as yet. But what happened to me was the validation worked. Worst case we may have to live with the space possibility if the TRIM is causing the odd behavior.