Hi,
I have 2 textboxes. One for the start date and one for the end date. When the End date is entered, I would like to validate that the end date is greater than the start date. This is what I have so far. I get the error:
Object does not support this property or method in line 11.
Javascript:
HTML Code:
I have 2 textboxes. One for the start date and one for the end date. When the End date is entered, I would like to validate that the end date is greater than the start date. This is what I have so far. I get the error:
Object does not support this property or method in line 11.
Javascript:
Code:
/***************************************************************************
This function ensures that date from the Input box is parsed to a Java Date Object.
*****************************************************************************/
function ParseDate(dateString)
{
//Date is in the format of mm/dd/yyyy pulled from textbox.
var dateSep = "/";
//firstSep = dateString.indexOf(dateSep);
//lastSep = dateString.lastIndexOf(dateSep);
date = dateString.split(dateSep, 3);
//alert(date[0] + ", " + date[1] + ", " + date[2]);
var date = new Date(date[2], date[0]-1, date[1]);
//alert(date); //parsing is working fine. returns the date object.
return date;
}
/*******************************************************************************
This function ensures that the users select a start date which is less than end date
*********************************************************************************/
function ValidateDate(startDateStr, endDateStr)
{
startDate = ParseDate(startDateStr);
endDate = ParseDate(endDateStr);
//alert(startDate.toString()); //here is the error - when it convert to a string it is returning funny values.
//alert(startDate.getDate());
if (endDate < startDate) {
alert("Start Date should be less than End Date");
}
//else
// alert("Bad");
}
HTML Code:
Code:
<form name="frmERP" action="" method=post>
<fieldset align="middle">
<legend>Select Search Criteria</legend>
<table border=0>
<tr >
<td colspan="2" align="right"></td>
</tr>
<tr >
<td align="right">Start Date:</td>
<td align="left"><input type="text" name="sStartDate" /></td>
</tr>
<tr>
<td align="right">End Date:</td>
<td align="left"><input type="text" name="sEndDate" onblur="ValidateDate(this.frmERP.sStartDate, this.frmERP.sEndDate)"/></td>
</tr>
<tr>
<td align="right">Table Name:</td>
<td align="left">
<select name="sTableName">
<option>--Select a table --</option>
<option>PO_SYSTEM_PARAMETERS_ALL</OPTION>
<option>AR_SYSTEM_PARAMETERS_ALL</option>
<option>AP_SYSTEMS_PARAMETERS_ALL</option>
<option>RCV_PARAMAETERS</option>
<option>MTL_PARAMETERS</option>
<option>All Tables</option>
</select>
</td>
</tr>
</table>
<div class="input_spacer"></div>
<input type="submit" value="Get Report"/>
</fieldset>
</form>