cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CatPagulayan
Helper IV
Helper IV

Text input field should not allow more than 4 decimal places

Hello, 

I have a formula in my text field which rounds up after 4 decimal places so that if the input is 1.23456 it becomes 1.2346 when entered.

What I want is to totally not allow more than 4 decimal places for numbers so that user can only input up to 1.2345 in the above number and will not allow the 5th decimal place. Is that possible? If yes, what is the formula and in which property do I need to put it? (onchange? default?)

thanks!

3 REPLIES 3
KrishnaV
Super User III
Super User III

Hi @CatPagulayan


On button submit to validate the text input value with the below regular expression:

IsMatch(TextInput1.Text,"^(\d{1,5}|\d{0,5}\.\d{1,4})$")

This will allow 5 digits and followed by 4 decimal places.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.
KrishnaV
Super User III
Super User III

Hi @CatPagulayan ,

 

Was this resolved your issue? just want to do a quick followup


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.
Prakash4691
Resolver II
Resolver II

Hi @CatPagulayan ,

 

I assume that text input contains number value. If so, please modify below properties of control as mentioned.

 

Modify "OnChange" property of text input to :

If(IsNumeric(DataCardValue4.Text) && IsMatch(DataCardValue4.Text, "\d+\.[0-9]*") && Len(DataCardValue4.Text) > 7, UpdateContext({length: 6}), UpdateContext({length: Parent.MaxLength})); If(IsBlank(DataCardValue4.Text), UpdateContext({length: 0}))

 

"MaxLength" property of text input to :

If(length = 0, Parent.MaxLength, length)

 

"OnVisible" property of screen to :

UpdateContext({length: 0})

 

Please mark it as solution. If it answers your question.

 

Give thumps up, if it near marks your requirement.

 

 

Regards,

Prakash

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (3,301)