Skip to main content
Answer

Attribute Input Mask: Numbers with Two Decimal Places

  • August 19, 2024
  • 5 replies
  • 399 views

Forum|alt.badge.img

Hello! I am trying to use an input mask to allow for numerical entry only where the number has two decimal places.

 

For instance, we manufacture parts that have dimensions such as 68.50” and 82.25”. I tried using the input masks ##.##” and 90.99” on the attribute itself but when I enter the values above I get the following results:

68.50” → 68._5”

82.25” → 82._2”.

 

I had figured out that we could use something such as 90.99#” but it then returns values as:

 

82.25” → 82._25”

 

This isn’t ideal and could get confusing. Is there anyway to force a number right after the decimal?

Also, I believe I found a bug in the system when it comes to these input masks. Using the 90.99#” input mask above, it registers the number but every time I click on the attribute and click off it reduces the number and adds a space.

 

Thank you!

Best answer by darylbowman

This regex (REGular EXpression) may suit your situation more:

/^(0|[1-9]\d*)(\.\d+)?$/

5 replies

darylbowman
Captain II
Forum|alt.badge.img+15
  • Answer
  • September 16, 2024

This regex (REGular EXpression) may suit your situation more:

/^(0|[1-9]\d*)(\.\d+)?$/


Forum|alt.badge.img
  • Freshman II
  • May 14, 2025

Hello,

I am trying to create a mask for dollar amounts.  we are using non-stock items to track our Capital equipment and use attributes to log purchase price.

I have tried the mask $#,###,##0 

I have tried the reg expression of ^\d{1,7}(\.\d{1,2})?$, (and a couple other variations, Thanks Chat GPT)

but the combo just isn’t working.  I want to be able to enter 12345.67 and mask $12,345 or $12,345 or 1234567.89 and get $1,234,567

 

Any thoughts?

 

Thanks,
Jeremy


darylbowman
Captain II
Forum|alt.badge.img+15

You’re hoping for two related-but-different outcomes: formatting and rounding (or technically truncation, in your example).

You haven’t really indicated what about it isn’t working. Have you tried the individual pieces separately?

I think regex will only prevent you from entering certain formats, not change the format. (You could prevent the user from entering numbers with decimals.)

Masking should display the number in a defined format (with , and $)


Forum|alt.badge.img
  • Freshman II
  • May 16, 2025

@darylbowman Well I was hoping for both…

If I want to enter 123.45 - 123456.78 how do I get $123 - $1,234,567?

When I enter the masks above it seems to work left to right and require the 7 digits or look funky.  Can i get the mask to grow from 3 to 7 digits?  

I tried this regex ^\d{3,7}$ and that limited the decimal point entry. 

Do I need to just format on the GI data?

 

Thanks

 


darylbowman
Captain II
Forum|alt.badge.img+15

​Do I need to just format on the GI data?

If that's the desired outcome, that would be much easier.