web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to limit number of...
Power Apps
Unanswered

How to limit number of spaces in text input boxes

(0) ShareShare
ReportReport
Posted on by 16

Hello, I'm wanting to know if there is a way to limit the number of spaces that can be used in text input boxes. I am creating a quiz that requires people to enter an answer into a text input and check if it is correct or not. I linked the input to a text label with TrimEnds to remove any spaces at the beginning and end of the input but I want to prevent multiple spaces to happen between words. 

 

In this scenario, the correct answer is Hepatitis B, this can be marked correct with/without capital letters or spaces at the beginning or end - however if someone puts a double space between the two words then it will mark it as incorrect. Is there a way around this, where I can substitute multiple spaces to single spaces only? I don't want people being marked as incorrect if they have entered the right answer with basic human error of click spacebar more than once

 

My check answers formula is as follows: 

 

If(
 IsMatch(
 Label1.Text,
 "Hepatitis B",
 MatchOptions.Complete & IgnoreCase
 ),
 UpdateContext({visibleCorrect: true});
 UpdateContext({visibleIncorrect: false})
);
If(
 Not(
 IsMatch(
 Label1.Text,
 "Hepatitis B",
 MatchOptions.Complete & IgnoreCase
 )),
 UpdateContext({visibleCorrect: false});
 UpdateContext({visibleIncorrect: true})
)

 

 

Here are examples of how the formula is currently operating: 

Sazdoug_0-1628473574694.png

Sazdoug_1-1628473598191.png

 

Categories:
I have the same question (0)
  • Verified answer
    v-albai-msft Profile Picture
    on at

    Hi @Sazdoug ,

    I would suggest you use the Trim function. The Trim function removes all spaces from a string of text except for single spaces between words. Here is an example:

    valbaimsft_0-1628477417845.png

     

    So you can try formula like below(or directly link the input to a text label with Trim function):

     

    IsMatch(
    	Trim(Label1.Text),
     "Hepatitis B",
     MatchOptions.Complete & IgnoreCase
     )

     

    Best regards,

    Allen

  • Sazdoug Profile Picture
    16 on at

    Thank you so much!!! Worked a treat 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard