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:
  • 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,650 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 283

#3
Mohsin Ali Profile Picture

Mohsin Ali 221

Last 30 days Overall leaderboard