Format Numbers in Form as They are Entered.

Format Numbers in Form as They are Entered.

I have a form that performs calculations. I was wondering if it is possible to format a number with commas as it is entered? For example if someone enters 1000000 a comma would appear after the 1 and the third 0 when the third and sixth 0 is entered to make it 1,000,000. The form should allow the user to enter a decimal if required. If this is possible how can I accomplish this?