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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Limit the number of Ch...
Power Apps
Answered

Limit the number of Characters in an Alphanumeric field based on the value chosen in another field?

(0) ShareShare
ReportReport
Posted on by 90

Example

 

I have a field that for line of business that has 3 choices (dropdown)  Choice 1, Choice 2 & Choice 3.

 

I have another field that is Client number (Alphanumeric field)  that I would like to limit as follows

 

if Line of business is,

choice 1 then I can enter a client number with a Maximum of 8 characters

choice 2 then I can enter a client number with a Maximum of 5 characters

choice 3 then I can enter a client number with a Maximum of 10 characters

 

I would be grateful if anyone has a solution as I have not been able to find a way of doing this.

 

Thanks

Categories:
I have the same question (0)
  • Verified answer
    jorge.daniel Profile Picture
    1,430 Super User 2024 Season 1 on at

    Hi,

     

    Is it a TextInput? If so, you can leverage the MaxLength property.

     

    Use your choices to set a variable, for instance varLenght and then set the MaxLenght to varLenght.

     

    Regards

  • EddieE Profile Picture
    4,641 Moderator on at

    @TJCappy 

    @jcfDaniel  is on the right track, use the MaxLength property of a TextInput control. 

     

    For example:

    Dropdown named ddChoices has this code

    // Items
    ["Choice 1", "Choice 2", "Choice 3"]
    
    // OnChange
    Reset(ChoiceInput)

     

    TextInput control named ChoiceInput has this code

    // Default
    ""
    
    // MaxLength
    Switch(
     ddChoices.Selected.Value,
     "Choice 1", 8 ,
     "Choice 2", 5 ,
     "Choice 3", 10 
    )

     

    Add a label underneath the TextInput with this code

    // Text property
    Switch(
     ddChoices.Selected.Value,
     "Choice 1", 8 - Len(ChoiceInput.Text) & " charcaters left.",
     "Choice 2", 5 - Len(ChoiceInput.Text) & " charcaters left.",
     "Choice 3", 10 - Len(ChoiceInput.Text) & " charcaters left."
    )

     

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard