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
Super User

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
Super User

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
Super User
Super User

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 Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,156)