NGJ
05-22-2006, 06:55 PM
Hi,
I'm using Jason's Date Input Calendar, within a Form, to display the current date and to allow the user to select a 'response by' date. I want the validation to alert the user if the second date they've selected is in the past.
The following code achieves this, but upon clicking 'ok' to the pop-up alert box - the Form posts regardless.
Can anyone help please? :confused:
The basic code is as follows:
<html>
<head>
<script type="text/javascript" src="calendarDateInput.js">
</script>
</head>
<body>
<script type="text/javascript">
function validateTheDate() {
var Today = new Date();
if (Response_Requested_By_Object.picked.date < Today) alert('Cannot select a date in the past.');
else if (Response_Requested_By_Object.picked.yearValue > 2020) alert('Cannot select dates beyond 2020.');
}
</script>
<form method="post" action="../mailing.asp" Name="Form" onSubmit="validateTheDate();">
<table>
<tr>
<td colspan="2">Date Requested</td>
<td><script>DateInput('CCN_Request_Date', true, 'DD-MON-YYYY')</script></td>
</tr>
<tr>
<td colspan="2">Response Requested By</td>
<td><script>DateInput('Response_Requested_By',true, 'DD-MON-YYYY')</script></td>
</tr>
</table>
<table>
<td><input type="Submit" value="Finish!"></td>
</table>
</form>
</body>
</html>
I'm using Jason's Date Input Calendar, within a Form, to display the current date and to allow the user to select a 'response by' date. I want the validation to alert the user if the second date they've selected is in the past.
The following code achieves this, but upon clicking 'ok' to the pop-up alert box - the Form posts regardless.
Can anyone help please? :confused:
The basic code is as follows:
<html>
<head>
<script type="text/javascript" src="calendarDateInput.js">
</script>
</head>
<body>
<script type="text/javascript">
function validateTheDate() {
var Today = new Date();
if (Response_Requested_By_Object.picked.date < Today) alert('Cannot select a date in the past.');
else if (Response_Requested_By_Object.picked.yearValue > 2020) alert('Cannot select dates beyond 2020.');
}
</script>
<form method="post" action="../mailing.asp" Name="Form" onSubmit="validateTheDate();">
<table>
<tr>
<td colspan="2">Date Requested</td>
<td><script>DateInput('CCN_Request_Date', true, 'DD-MON-YYYY')</script></td>
</tr>
<tr>
<td colspan="2">Response Requested By</td>
<td><script>DateInput('Response_Requested_By',true, 'DD-MON-YYYY')</script></td>
</tr>
</table>
<table>
<td><input type="Submit" value="Finish!"></td>
</table>
</form>
</body>
</html>