CustomValidator client-side scripting

J

John Bonds

I'm having some problems with implementing client-side validation in a user
control. Here' my code for the usercontrol:

<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="uclPayment.ascx.vb" Inherits="maestroglass.uclPayment"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<script language="vbscript">
Sub ValidateExpirationDate(source, args)
'MsgBox(document.forms)
Dim pFormDate As Date = DateValue("1/" &
ddlExpirationMonth.SelectedItem.Value & "/" &
ddlExpirationYear.SelectedItem.Value)
If DateDiff("M", Now, pFormDate) >= 0 Then
args.IsValid = True
Else
args.IsValid = False
End If
End Sub
</script>
<TABLE id="htbLayout" style="BORDER-RIGHT: thin outset; BORDER-TOP: thin
outset; BORDER-LEFT: thin outset; BORDER-BOTTOM: thin outset"
cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<TD width="150">Payment Method</TD>
<TD>Credit Card No.</TD>
<TD width="200">Expiration Date</TD>
</TR>
<TR>
<TD><asp:dropdownlist id="ddlCreditCardType" runat="server">
<asp:ListItem Value="VISA" Selected="True">VISA</asp:ListItem>
<asp:ListItem Value="Master Card">Master Card</asp:ListItem>
<asp:ListItem Value="American Express">American Express</asp:ListItem>
<asp:ListItem Value="Discover">Discover</asp:ListItem>
</asp:dropdownlist></TD>
<TD><asp:textbox id="tbxCreditCardNum" runat="server"
Width="200px"></asp:textbox><asp:requiredfieldvalidator
id="reqCreditCardNum" runat="server" ErrorMessage="Please enter a credit
card number"

ControlToValidate="tbxCreditCardNum"></asp:requiredfieldvalidator><asp:custo
mvalidator id="cuvCreditCardNum" runat="server" ErrorMessage="Credit Card
number is invalid"
ControlToValidate="tbxCreditCardNum"></asp:customvalidator></TD>
<TD><asp:dropdownlist id="ddlExpirationMonth" runat="server">
<asp:ListItem Value="1" Selected="True">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
<asp:ListItem Value="6">6</asp:ListItem>
<asp:ListItem Value="7">7</asp:ListItem>
<asp:ListItem Value="8">8</asp:ListItem>
<asp:ListItem Value="9">9</asp:ListItem>
<asp:ListItem Value="10">10</asp:ListItem>
<asp:ListItem Value="11">11</asp:ListItem>
<asp:ListItem Value="12">12</asp:ListItem>
</asp:dropdownlist><asp:dropdownlist id="ddlExpirationYear"
runat="server"></asp:dropdownlist><asp:customvalidator id="cuvExpiration"
runat="server" ErrorMessage="Expiration is invalid"
</TR>
</TABLE>


Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top