【发布时间】: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;
}
【问题讨论】:
-
对我来说都是正确的...... ^^ 但这可能不是使用的最佳解决方案......
-
罗伯特不是这个意思,他不想验证这是一个正确的号码,他想从 txtCardNum 中检索信用卡号码。