如何检索信用卡类型的值

本文关键字:信用卡 类型 检索 何检索 | 更新日期: 2023-09-27 18:02:23

我需要做的是客户验证器。我在代码后面的代码需要查看信用卡类型以及信用卡号码。我不知道该怎么做。

    <asp:DropDownList ID="ddlCCType" runat="server">
       <asp:ListItem Value="None">Select Card Type</asp:ListItem>
       <asp:ListItem Value="Visa">Visa</asp:ListItem>
       <asp:ListItem Value="Amex">Amex</asp:ListItem>
       <asp:ListItem Value="Mastercard">Mastercard</asp:ListItem>
    </asp:DropDownList>
    <asp:TextBox ID="txtCardNum" runat="server" Width="200px"></asp:TextBox>

    <asp:CustomValidator runat="server" id="cusCustom" controltovalidate="txtCardNum" onservervalidate="txtCard_ServerValidate" errormessage="The credit card is incorrect." />

我有下面的代码,但不确定如何检索信用卡类型的值。e.Value将只返回信用卡号的值。

    protected void txtCard_ServerValidate(object sender, ServerValidateEventArgs e)
    {
      if(e.Value.Length == 8)
       ......
       e.IsValid = true;
      else
       e.IsValid = false;
    }

如何检索信用卡类型的值

这个想法是根据卡号的范围来验证其品牌。你知道的:- Visa卡以4开头-美国运通卡以37开头(或34,不确定了)-万事达卡以5开头

如果您更改列表中项目的值,使其反映卡片范围,则可以验证卡号是否以所选项目的值开始。

哔叽