Catalog variable to accept decimal values up to 2 digits?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 05:25 AM
Catalog variable to accept decimal values up to 2 digits?
it should take whole number but only 2 decimal place should be allowed for decimal value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 05:37 AM - edited 01-30-2024 05:44 AM
Hi @sonali bhagat,
A common question that has been solved numerous times in the community.
Let me help recycle someone else's hard work and point you to the following link for solving a $ (Dollar) currency value:
Please note, if you just want 2 decimal places and not a specific currency for example, you can use:
Regex: var reg = /^[0-9]*\.[0-9]{2}$/;
Or regular javascript class: var roundValue = parseFloat(newValue).toFixed(2);
To help others in the community (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 05:48 AM
for catalog variable validation follow the below process
1. open that particular catalog item
2. open a variable that you want to validate
3. under variable, there is a "Type Specification" related list section
there is a field "validation Rejex" Select the Number option and open records in a different tab and add regular exprestion
^\d+\.\d\d$
and save and select a number from the dropdown of validation rejex field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 02:34 AM - edited 02-05-2024 05:58 AM
Hi @sonali bhagat,
Did you see my earlier response? Please let me know if I can help close this out for you?
This is a common question that has been solved numerous times in the community.
Let me help recycle someone else's hard work and point you to the following link for solving a $ (Dollar) currency value:
Please note, if you just want 2 decimal places and not a specific currency for example, you can use:
Regex: var reg = /^[0-9]*\.[0-9]{2}$/;
Or regular javascript class: var roundValue = parseFloat(newValue).toFixed(2);
@sonali bhagat To help others in the community (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie