1. ## Set decimal automatically

I'm entering a number into a field and I want the decimal point to automatically land 2 positions over.

For example:
User enters: 2999
Field Displays: 29.99

All doing without hitting the decimal point key.

I've found a few threads on this but they're from 2008. I figure Alpha might have come up with a way to do this that I'm not seeing. This is similar to the setting on a calculator for accounting so you can skip the . key and it automatically puts it where you want it.

Any help would be much appreciated.

2. ## Re: Set decimal automatically

You could use Client side formatting with a "Custom" Format definition. In the Format definition the radio button should be set to Number and your Parse Out could be...

Code:
`data = (data/100).toFixed(2)`

3. ## Re: Set decimal automatically

Almost. When I go back to the field, it's rounding another 2 spaces to the left.

If I enter say 49599, it shows 495.99. When I refresh that page it rounds it to 4.96. So it's rounding to the left again.

4. ## Re: Set decimal automatically

Indeed. I didn't test going back in and out after the decimal was set. By the in-line doc I thought the decimal symbols got stripped out. I guess everything else gets removed except for the decimal.

So... change the Type to String. This leaves the incoming value alone. Then use this code in Parse Out...

Code:
```var noDec = data.replace(".",'')
data = (noDec/100).toFixed(2)```
Or... to be a little safer if you're using other symbols, such as thousands separator... leave the Type as Number and use this code...

Code:
```var noDec = parseInt(data.toString().replace(".",''))
data = (noDec/100).toFixed(2)```
Alpha converts the string into a number removing everything except the decimal. We then convert the number to a String, remove the decimal, convert the number to an integer and put the decimal back in.

5. ## Re: Set decimal automatically

That worked. Thanks! I was putting that /100 everywhere and couldn't quite get it to work right.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•