473,382 Members | 1,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

CustomValidator client-side scripting

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"
ClientValidationFunction="ValidateExpirationDate"> </asp:customvalidator></TD

</TR>
</TABLE>
Thanks
Nov 18 '05 #1
0 1438

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: jcpmeticulus | last post by:
Hi I've spent the last day or so debugging a problem with a CustomValidator and am now totally stumped! Basically I use a number of CustomValidator's on my page, but have cut this down now to...
1
by: Jon Davis | last post by:
I have a CustomValidator control, to which I've assigned a Javascript function name in the ClientValidationFunction property of the control. Example client function (Jscript): <script>...
2
by: Stephen Miller | last post by:
Can the CustomValidator be used to simply report unexpected errors, without requiring Client/Server validation? To explain, say you had a simple text box and button that did a Full-text Search of a...
1
by: SMG | last post by:
Hi All. My forms has two textboxes, 1 username, 2 password. Both has requiredfield validator it works fine when there is no input in these textboxes. And the errorMsg is shown in...
0
by: ghafranabbas | last post by:
This is how you use the customvalidator control in any INamingContainer interface control (Datagrid, DataList, DataRepeater, etc). 1. In the ItemTemplate, place your customvalidator 2. Set the...
1
by: Luke Morehead | last post by:
We want to require a value for CboCharity if the value for cboCardSource = Fundraiser. Here's the client script: <script language="javascript"> <!-- function ValidateCharity(source, arguments)...
1
by: Damon | last post by:
I'd like to be able to modify the error message of an ASP.NET 2.0 customValidator on the fly, depending on what part of the validation failed. Now, the client validation function takes two...
3
by: Stan SR | last post by:
Hi, I have a web user control that contains 3 dropdownlists it's a date selector, so one contains the days, one the months and the last the years. Each of them starts with a blank value. I...
2
by: Epetruk | last post by:
Hello, I have an ASP.NET page which consists of a button (cmdSave), a label (lblMessage), a text field (txtName) and a custom validator (vldName). vldName is supposed to do both client *and*...
2
by: Mr. X. | last post by:
Hello. How can I control the position of customValidator. I have code like this (ASP.NET) <asp:CustomValidator dir = "rtl" CHARSET=WINDOWS-1255" id = "email_err" ControlToValidate="a_email"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.