I'm getting an error that only appears on the great IE8, it points to the following function, specifically the line: return (expDate.getTime() > Date.now());
$.validator.addMethod("checkDocExpiry",function(value) {
var driverLicExp = ($('#drivers-license-expiration').val()) ? $('#drivers-license-expiration').val() : '';
if (driverLicExp != ''){
var expDate = new Date(driverLicExp);
return (expDate.getTime() > Date.now());
}else{
return (true);
}
}, "Your driver's license has expired.");
I'm not sure what would cause this, I am fairly new to developing for older browsers. This runs fine in FF, IE10, Chrome, Safari.
Any help would be much appreciated.
Thanks
Looks like Date.now()
isn't supported in IE8 (see the table at the bottom):
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now
new Date()
should get you a date object with the current date.
Shim using the fact valueOf a Date is ms..
if (!Date.now) Date.now = function () {return +new Date();};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With