我需要做的是客户验证器。我在代码后面的代码需要同时查看信用卡类型和信用卡号码。我不知道该怎么做。
<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;
}发布于 2013-03-05 00:04:16
这个想法是根据卡号的范围来验证卡号的品牌。您知道:-Visa卡以4开头- AmEx卡以37开头(或34,不再确定)-万事达卡以5开头
如果更改列表中项目的值,使其反映卡范围,则可以验证卡号是否以所选项目的值开头。
Serge
https://stackoverflow.com/questions/15205511
复制相似问题