# Incorporating commas into text fields

**URL:** <https://forum.kirupa.com/t/incorporating-commas-into-text-fields/316472>\
**Category:** Uncategorized\
**Created:** [November 22, 2010, 11:33pm UTC](https://forum.kirupa.com/t/incorporating-commas-into-text-fields/316472 "2010-11-22T23:33:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SlimSr\_2003](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@SlimSr\_2003](https://forum.kirupa.com/u/SlimSr_2003)\
**Post date:** [November 22, 2010, 11:33pm UTC](https://forum.kirupa.com/t/incorporating-commas-into-text-fields/316472/1 "2010-11-22T23:33:19Z")

</div>

Ok, I have looked around and I know that this question has been asked many times but I still dont understand. I am developing an ROI calculator and need to acomplish two things, i think one will fix the other but here goes. 1. I need to make sure that when a user inputs their number in the input text field if they us a comma I dont get the NaN as a return. 2. How can I incorporate commas into the final calculation answer. For example if they enter 10000 my net result currently comes back as 105600. I would like it to come back as 105,600. I dont necessarly need to format as currency to make this work.

I am using CS5 and AS3 for the coding on this. I am not very expierenced in coding in Flash, as a matter of fact the fact that I have made it this far is amazing.

Here is my current code:

stop();  
CalcBtn.addEventListener(MouseEvent.MOUSE\_UP, FindTotal);  
function formatNumbers(num:Number, comma:Boolean):String {  
var userInput:Number = Number(Input.text);  
var myFailure:Number = Number(Failure.text);  
var myLostOpp:Number = Number(LostOpp.text);  
var myShrinkBudget:Number = Number(ShrinkingBudgets.text);  
var myOrganicGrowth:Number = Number(OrganicGrowth.text);

var TheFailure:Number = userInput\* 24;  
Failure.text = String(TheFailure);

var TheLostOpp:Number = userInput\* 24;  
LostOpp.text = String(TheLostOpp);

var TheShrinkingBudgets:Number = userInput\* 24\* .1;  
ShrinkingBudgets.text = String(TheShrinkingBudgets);

var TheOrganicGrowth:Number = userInput\* 24\* .1;  
OrganicGrowth.text = String(TheOrganicGrowth);

var TheTotal:Number = TheFailure+ TheLostOpp+ (TheShrinkingBudgets+ TheOrganicGrowth);  
Total.text = String(TheTotal);  
Total2.text = String(TheTotal);  
play()  
}

I have looked at other suggestions and plugged them in with no luck.

Can someone please walk me throught this. I need to have this finished by the 29th of this month (11/29) so any and all help would be greatly appreciated.

SlimSr
