Use TextInput as the Credit card number data source
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" verticalAlign="middle" horizontalAlign="center">
<mx:Script>
import mx.controls.Alert;
</mx:Script>
<mx:Model id="creditcard">
<card>
<cardType>{cardTypeCombo.selectedItem.data}</cardType>
<cardNumber>{creditCardInput.text}</cardNumber>
</card>
</mx:Model>
<mx:Panel title="Data Validation">
<mx:ComboBox id="cardTypeCombo">
<mx:dataProvider>
<mx:Object label="American Express" data="American Express" />
<mx:Object label="MasterCard" data="MasterCard" />
<mx:Object label="Visa" data="Visa" />
</mx:dataProvider>
</mx:ComboBox>
<mx:TextInput id="creditCardInput" restrict="1234567890" />
<mx:Button label="Validate" click="ccv.validate()" />
</mx:Panel>
<mx:CreditCardValidator id="ccv"
cardTypeSource="{creditcard}"
cardTypeProperty="cardType"
cardNumberSource="{creditcard}"
cardNumberProperty="cardNumber"
cardTypeListener="{cardTypeCombo}"
cardNumberListener="{creditCardInput}"
valid="Alert.show('Credit card is valid')" />
</mx:Application>
Related examples in the same category