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
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
Share Improve this question asked Aug 5, 2013 at 22:00 NeilNeil 2,5197 gold badges34 silver badges47 bronze badges 2 |4 Answers
Reset to default 10Looks 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();};
IE 8 does not support Date.now. Implement it as :
if(!Date.now) { Date.now = function(){ return new Date().getTime();};}
My psychic debugging skills tell me that you're using jQuery 2.0, which does not support IE8.
You need to use 1.10.
08/13/2013
– Neil Commented Aug 5, 2013 at 22:04