Return to the menu   Select another DES Module

Demonstrates the CreditCardNumberValidator

The CreditCardNumberValidator reviews the text pattern to confirm it matches the rules for credit card numbers.

This validator does not submit the credit card number against an online service. You must get other software for that and can use the IgnoreConditionValidator or CustomValidator to report errors from that service.

Specify the control to evaluate with the ControlIDToEvaluate property.

You have the option to review the number against known credit cards using these settings:

  • Set CheckByBrand to true. (It defaults to true.)
  • The credit card brands that you support are defined in the [web app]\DES\des.config and [web app]\DES\custom.des.config files. Open each of these files to the <CreditCards> section. des.config should not be edited. It is the factory list of supported cards. Use the custom.des.config file to remove factory defaults that you do not want and add new rules. Alternatively, you can programmatically assign credit card brand information to the CreditCardNumberValidator or CreditCardNumberCondition using the AddBrand() method.


Controls




Source Code (C#)

<script runat="server">
protected void Button1_Click(object sender, EventArgs e) { if (PeterBlum.DES.Globals.WebFormDirector.IsValid) { // save your data here } }
</script> <des:TextBox ID="TextBox1" runat="server" /> <des:CreditCardNumberValidator ID="CreditCardNumberValidator1" runat="server" ControlIDToEvaluate="TextBox1" ErrorMessage="Invalid credit card number" /> <br/> <br/> <des:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click"></des:Button>

Return to the menu   Select another DES Module