【问题标题】:How to retrieve the value of the credit card type如何检索信用卡类型的值
【发布时间】:2013-02-18 18:35:14
【问题描述】:

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

    <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;
    }

【问题讨论】:

标签: c# asp.net


【解决方案1】:

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

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

谢尔盖

【讨论】:

  • Serge,我如何检索信用卡的价值和信用卡类型。这是我的问题。谢谢
猜你喜欢
  • 2017-02-23
  • 1970-01-01
  • 2021-07-07
  • 1970-01-01
  • 2019-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-12
相关资源
最近更新 更多