Skip to main content
Community site session details

Community site session details

Session Id : TrWNVmQdM5wiw4YgZTE2Jp
Power Apps - Building Power Apps
Answered

Text field with space is not blank

Like (0) ShareShare
ReportReport
Posted on 23 May 2018 01:04:11 by

Hello, 

 

We require to enforce text input for 2 fields, which are linked to a collection. 

 

When the person wants to proceed and the fields are blank, the alert is shown (to indicate they are required). 

However, people are still able to circumvent that by entering spaces. PowerApps picks this up as text and thus does not consider this textfield 'blank' anymore. 

 

Is there a function that checks whether a field includes data (and considers an entry that includes spaces only as 'blank')?

 

If(IsBlank(textinputTaskLocation), UpdateContext({Alert1: true}));
If(IsBlank(textinputTaskDescription), UpdateContext({Alert2: true}));
If(!IsBlank(textinputTaskLocation), UpdateContext({Alert1: false}));
If(!IsBlank(textinputTaskDescription), UpdateContext({Alert2: false}));

If(!IsBlank(textinputTaskLocation) && !IsBlank(textinputTaskDescription), 
Navigate(InspectionScreen1, Fade), false)

1.JPG

Categories:
  • Community Power Platform Member Profile Picture
    on 23 May 2018 at 03:32:52
    Re: Text field with space is not blank

    Hi CMee and 

     

    Thanks for your solutions! 🙂

    In my particular case the syntax provided by dinusc works, however CMee your suggestion is also a good one. 

  • Verified answer
    dinusc Profile Picture
    Microsoft Employee on 23 May 2018 at 02:16:42
    Re: Text field with space is not blank

    Sorry. My bad. The formula should be:

    If(IsBlank(Trim(textinputTaskDescription.Text)), UpdateContext({Alert2: true}), UpdateContext({Alert2: false}));

  • CMee Profile Picture
    72 on 23 May 2018 at 02:13:43
    Re: Text field with space is not blank

     

    IsBlank(Substitute(textinputTaskDescription.Text," ",""))

    This will return true for any string that is a series of spaces.

     

    On a more general note however, I tend to lean more towards checking the length of the provided string when validating text fields.This way you can check if the user entered anything that is a single character (like ".' or " " for instance) to circumvent the field.

     

    Although I don't know your specific circumstances I would use something like this:

     

    UpdateContext({Alert1: !Len(textinputTaskLocation.Text)>1});
    UpdateContext({Alert2: !Len(textinputTaskDescription.Text)>1})

    This would enforce a minimum of 2 characters in both of your fields and updates your Alert variables. You could also combine these two for an even more robust validation that checks minimum length and checks for the entering of spaces.

     

    UpdateContext({Alert1: !Len(Substitute(textinputTaskLocation.Text," ",""))>1});
    UpdateContext({Alert2: !Len(Substitute(textinputTaskDescription.Text," ",""))>1})

     

  • Community Power Platform Member Profile Picture
    on 23 May 2018 at 02:09:34
    Re: Text field with space is not blank

    Thanks - Yes I tried this:

    The alert will only show up if the field is really blank. As soon as I add a space the alert does now show anymore.

  • dinusc Profile Picture
    Microsoft Employee on 23 May 2018 at 02:06:05
    Re: Text field with space is not blank

    Can you please try the following:

    If(IsBlank(textinputTaskDescription.Text), UpdateContext({Alert2: true}), UpdateContext({Alert2: false}));

  • Community Power Platform Member Profile Picture
    on 23 May 2018 at 01:56:09
    Re: Text field with space is not blank

    Hi  

     

    Thanks for your suggestion.

     

    However the Trim() or TrimEnds() function did not work here.

    I assume because they refer to removing spaces before/after/between strings and therefore does not work if there is no string?

     

    It does work to add the following condition, but then I'll need to add this multiple times to account for several space entries. It just does not seem like an elegant way 😉

     

    If(textinputTaskDescription.Text = " ", UpdateContext({Alert2: true}));
    If(textinputTaskDescription.Text = " ", UpdateContext({Alert2: true}));
    If(textinputTaskDescription.Text = " ", UpdateContext({Alert2: true}));
    If(textinputTaskDescription.Text = " ", UpdateContext({Alert2: true}));
    If(textinputTaskDescription.Text = " ", UpdateContext({Alert2: true}));
  • dinusc Profile Picture
    Microsoft Employee on 23 May 2018 at 01:44:26
    Re: Text field with space is not blank

    Hello DanielaH,

     

    You should be able to use "Trim" function to get rid of all the spaces before checking the field value. Please see this page: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-trim

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2