RobColborne
MIS
Hi
Trying to compare a date in a text field with the current date to check for expiry. Have looked at this forum and thought I have found the answer but having issues.
Having put some alerts() in the code the form data returns in the following format: 'dd/mm/yyyy hh:mm', for testing the data in the form is 14/06/2005.
But after the Date.Parse command it returns 'Mon Feb 6 00:00:00 UTC 2006' - do I need to do something with the form data? I thought that it was already in date format.
My code is as follows:
Trying to compare a date in a text field with the current date to check for expiry. Have looked at this forum and thought I have found the answer but having issues.
Having put some alerts() in the code the form data returns in the following format: 'dd/mm/yyyy hh:mm', for testing the data in the form is 14/06/2005.
But after the Date.Parse command it returns 'Mon Feb 6 00:00:00 UTC 2006' - do I need to do something with the form data? I thought that it was already in date format.
My code is as follows:
Code:
<script language="javascript">
window.onload = function pd()
{
if (document.all._HIDDENpers_passport) {
var pd =document.all._HIDDENpers_passport.value;
}
else
{
var pd=document.all.pers_passport.value;
}
var passportdate = new Date();
var currentdate = new Date();
passportdate.setTime(Date.parse(pd));
if (passportdate < currentdate){
alert ("Passport had expired");
}
}
</script>