PDA

View Full Version : Invalid Date object



Magnatron
Oct 28th, 2002, 05:13 PM
When trying to validate a date input field on a form, I am getting a ' document.frmPOExpReq.RevReqstShipDate[intLineNumber-1].value is null or not an object' error message when the field is referenced error message on 1 NT server and not another.

The field is:

<body BGCOLOR="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad vlink="#6699FF">
<span class="formBOLD"></span>
<form name="frmPOExpReq" method="post" action="javascript:btnChgDate_onmouseup()" >

<TD class="form" height="32" width="50" align="center"> <font color="#00000" FACE="Verdana"><input type="text" size="8" name="RevReqstShipDate" value="10/12/02" language="javascript" onblur="return PerformValidateDate(1.00000)"></FONT></td>


And the reference is:

function PerformValidateDate( intLineNumber ) {
var aiDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var iDay;
var iMonth;
var iYear;
var sDate = ( document.frmPOExpReq.RevReqstShipDate[intLineNumber-1].value);


Any suggestions would be greatly appreciated.

Thanks, in advance for your time,
Mark

Roy Sinclair
Oct 28th, 2002, 07:01 PM
Why not use the this operator:



<input type="text" size="8" name="RevReqstShipDate" value="10/12/02" language="javascript" onblur="return PerformValidateDate(this)">

function PerformValidateDate(formField) {
var aiDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var iDay;
var iMonth;
var iYear;
var sDate = ( formField.value);

...


The this operator is useful for passing a reference to the object being declared to functions so that you don't have to code the function with exact references and thus makes the function usable with a lot more fields and perhaps portable to additional pages.

Magnatron
Oct 28th, 2002, 07:25 PM
I'll give it a try. I appreciate your help.