Formating a text cell with spaces

I have text cells that I will be entering numbers into. I'd like to format them with comma's and then with 3 or 4 spaces where the period would be (i.e. 1,234.56 would be 1,234 56). Is this possible.


Michael Fournier


Voted Best Answer

I assume that you mean form fields when you say "text cells". In that case, you can do this with a custom format script. Bring up the properties for your field, go to the "Format" tab and select a custom format script. Use the following code as your script:

var n = event.value;
var parts=n.toString().split(".");
n = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (parts[1] ? "." + parts[1] : "");
n = n.replace(/\./, " ");

event.value = n;

Karl Heinz Kremer
PDF Acrobatics Without a Net
PDF Software Development, Training and More...
http://www.khkonsulting.com


By Karl Heinz Kremer   


Please specify a reason: