rafaelmaeuer
2/14/2017 - 4:17 PM

Restrict Decimal Places for Textfields - From https://supportforums.blackberry.com/t5/Adobe-AIR-Development/textField-restrict-how-to-just-a

function restrictDecimalPlaces(evt:TextEvent):void
	{
	var matches:Array = evt.currentTarget.text.match(/\./g);
	var allowedDecimalPlaces:uint = 2;
   
	if	((evt.text == "." && matches.length >= 1) ||
		(matches.length == 1 && (evt.currentTarget.text.lastIndexOf(".") + allowedDecimalPlaces < evt.currentTarget.text.length)))
		evt.preventDefault();
	}