I see there are a ton of posts for custom validators, but my issue isn't resolved in any of them as far as I could tell...
I'm trying to use a client side custom validator with Javascript as the validating language.
What I'm seeing is my custom validations aren't firing correctly. If I click on the submut button slowly I can see the marker show next to the field, but then it goes away and the validation summary only shows the required validation fields as incorrect.
I have no clue why it's going this and I'm pulling my hair out... here's the code:
KizMar
------------
I'm trying to use a client side custom validator with Javascript as the validating language.
What I'm seeing is my custom validations aren't firing correctly. If I click on the submut button slowly I can see the marker show next to the field, but then it goes away and the validation summary only shows the required validation fields as incorrect.
I have no clue why it's going this and I'm pulling my hair out... here's the code:
Code:
<%@ Page Language="vb" ContentType="text/html" ResponseEncoding="iso-8859-1" CodeBehind="entryBasic.aspx.vb" AutoEventWireup="false" Inherits="time.entryBasic" %>
<%@ Register TagPrefix="MenuControl" TagName="Menu" Src="includes/menu.ascx" %>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "[URL unfurl="true"]http://www.w3.org/tr/html4/loose.dtd">[/URL]
<html>
<head>
<title>Maximize TimeTracker</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../includes/styles.css" type=text/css rel=stylesheet>
<link href="../includes/i_styles.css" type=text/css rel=stylesheet>
<link href="../includes/links.css" type=text/css rel=stylesheet>
<script language="javascript" src="includes/calcMiles.js"></script>
<script language="javascript" src="includes/datePicker.js"></script>
<script language="javascript" src="includes/val_classes.js"></script>
<script language="javascript">
// Check that a client has been selected
function CheckClientList(source, arguments) {
alert(argument);
if (arguments.value == 'Select')
arguments.IsValid=false;
else
arguments.IsValid=true;
}
}
// Check that a category has been selected
function CheckCategory(source, arguments) {
}
</script>
</head>
<body class="bodyMain">
<table cellspacing="0" cellpadding="0" width="797" align="center" border="0">
<!--#include file="../includes/header.htm"-->
<tr>
<td valign="top" align="left" background="../images/index_06.gif" colspan="3" height="564">
<!-- BEGIN Actual Body -->
<table height="100%" cellspacing="0" cellpadding="0" width="100%" border="0">
<form id="Form1" name="frmBasicInfo" action="details.aspx" method="post" runat="server"> <!-- BEGIN Form -->
<tr>
<td valign="top" width="136" bgcolor="#716b99" height="572">
<menucontrol:menu id="Menu1" runat="server" name="Menu1"></menucontrol:menu>
</td>
<td valign="top">
<div class="txtBGray" style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; PADDING-BOTTOM: 4px; PADDING-TOP: 0px">
<a class="lnkMBlue" href="index.aspx" >Employees</a> > New Entry<br>
<br>
<span class="txtXLRed">TimeTracker</SPAN><br>
<br>
<asp:validationsummary id="valSummary" runat="server" headertext="The form could not be submitted for the following reason(s):"></asp:validationsummary>
</DIV>
<!-- BEGIN Basic Info table -->
<table class="hdBorder" cellspacing="1" cellpadding="2" width="475" align="center" border="0">
<tr>
<td class="formTitle" align="center" colspan="2">Basic Information</TD>
</TR>
<tr>
<td nowrap align="right">Date</TD>
<td nowrap align="left">
<asp:textbox id="txtDate" runat="server" maxlength="10" columns="10"></asp:textbox>
<!-- Validate the above field -->
<asp:requiredfieldvalidator id="valDateExists" runat="server" display="Dynamic" controltovalidate="txtDate"
errormessage="Date field is empty">
<img src="../images/error_bullet.gif" align="absmiddle">
</asp:requiredfieldvalidator>
<asp:regularexpressionvalidator id="valDateCorrect" runat="server" display="Dynamic" controltovalidate="txtDate"
validationexpression="(0[1-9]|1[012])[/ /.](0[1-9]|[12][0-9]|3[01])[/ /.](19|20)\d\d" errormessage="Date is not in format: mm/dd/yyyy">
<img src="../images/error_bullet.gif" align="absmiddle">
</asp:regularexpressionvalidator>
<a onmouseover="window.status='Date Picker';return true;" onmouseout="window.status='';return true;" href="javascript:show_calendar(this);" >
<img src="images/show-calendar.gif" align="absMiddle" border="0">
</a>
</TD>
</TR>
<tr>
<td nowrap align="right">Client</TD>
<td align="left">
<asp:dropdownlist id="ddlClientList" runat="server"></asp:dropdownlist>
<!-- Validate the above field -->
<asp:customvalidator id="valClientList" runat="server" display="Dynamic" controltovalidate="ddlClientList"
errormessage="A client must be selected" clientvalidationfunction="CheckClientList">
<img src="../images/error_bullet.gif" align="absmiddle">
</asp:customvalidator>
</TD>
</TR>
<tr>
<td align=right>Category</TD>
<td align=left>
<asp:dropdownlist id="ddlCategory" runat="server"></asp:dropdownlist>
<!-- Validate the above field -->
<asp:customvalidator id="valCategory" runat="server" display="Dynamic" controltovalidate="ddlCategory"
errormessage="A category must be selected" clientvalidationfunction="CheckCategory">
<img src="../images/error_bullet.gif" align="absmiddle">
</asp:customvalidator>
</TD>
</TR>
<tr>
<td nowrap align="right">From</TD>
<td align="left">
<asp:textbox id="txtFromHour" runat="server" maxlength="5" columns="5"></asp:textbox>
<!-- Validate the above field -->
<asp:requiredfieldvalidator id="valFromHour" runat="server" display="Dynamic" controltovalidate="txtFromHour"
errormessage="Start time is empty">
<img src="../images/error_bullet.gif" align="absmiddle">
</asp:requiredfieldvalidator>
<i>to</I>
<asp:textbox id="txtToHour" runat="server" maxlength="5" columns="5"></asp:textbox>
<!-- Validate the above field -->
<asp:requiredfieldvalidator id="valToHour" runat="server" display="Dynamic" controltovalidate="txtToHour"
errormessage="End time is empty">
<img src="../images/error_bullet.gif" align="absmiddle">
</asp:requiredfieldvalidator>
<i>Do not include travel time.</I>
</TD>
</TR>
<tr>
<td nowrap align="right">Billable Hours</TD>
<td align="left">
<asp:textbox id="txtBillableHours" runat="server" maxlength="3" columns="3"></asp:textbox>
<!-- Validate the above field -->
<asp:customvalidator id="valBillableHours" runat="server" display="Dynamic"
clientvalidationfunction="CheckBillableHours" controltovalidate="txtBillableHours"
errormessage="Billable hours is empty (Enter 0 if none)">
<img src="../images/error_bullet.gif" align="absmiddle">
</asp:customvalidator>
<i>Non-billable</I>
<asp:textbox id="txtNonBillableHours" runat="server" maxlength="3" columns="3"></asp:textbox>
<!-- <asp:customvalidator id="valNonBillableHours" runat="server" display="Dynamic"
clientvalidationfunction="CheckNonBillableHours" controltovalidate="txtNonBillableHours"
errormessage="Non-billable hours is empty (Enter 0 if none)">
<img src="../images/error_bullet.gif" align="absmiddle">
</asp:customvalidator> -->
</TD>
</TR>
<tr>
<td nowrap align="right">Total Miles</TD>
<td>
<asp:textbox id="txtTotalMiles" runat="server" maxlength="3" columns="3"></asp:textbox>
<!-- Validate the above field -->
<asp:customvalidator id="valTotalMiles" runat="server" display="Dynamic"
clientvalidationfunction="CheckTotalMiles" controltovalidate="txtTotalMiles" errormessage="Total Miles">
<img src="../images/error_bullet.gif" align="absmiddle">
</asp:customvalidator>
<i>Miles to Expense</I>
<asp:textbox id="txtExpMiles" runat="server" maxlength="3" columns="3" readonly="True"></asp:textbox>
<!-- Validate the above field -->
<asp:customvalidator id="valExpMiles" runat="server" display="Dynamic" clientvalidationfunction="CheckExpMiles"
controltovalidate="txtExpMiles" errormessage="Miles to Expense">
<img src="../images/error_bullet.gif" align="absmiddle">
</asp:customvalidator>
</TD>
</TR>
<tr>
<td nowrap align="right">Brief Description</TD>
<td>
<asp:textbox id="txtShortDesc" runat="server" maxlength="45" columns="45"></asp:textbox>
<!-- Validate the above field -->
<asp:customvalidator id="valShortDesc" runat="server" display="Dynamic" clientvalidationfunction="CheckShortDesc"
controltovalidate="txtShortDesc" errormessage="Short Description">
<img src="../images/error_bullet.gif" align="absmiddle">
</asp:customvalidator>
</TD>
</TR>
<tr>
<td> </td>
<td align="right">
<asp:button id="btnSubmit" runat="server" text="Save & Continue..."></asp:button>
</TD>
</tr>
</TABLE>
<!-- END Basic Info table -->
</TD>
</TR>
</FORM> <!-- END Form -->
</TABLE>
<!-- END Actual Body -->
</td>
</tr>
<tr>
<td colspan="3" background="../images/index_05.gif" width="816" height="37" align="center">
<!--#include file="../includes/footer.htm"-->
</td>
</tr>
</table>
</body>
</html>
KizMar
------------