javascript date validation working in chrome but not in safari
For reference i have sent code, this code is working in chrome browser but not in safari.
how to do this? please help me.
function isToday(dateParameter) {
var today = new Date();
return dateParameter.getDate() === today.getDate() && dateParameter.getMonth() === today.getMonth() && dateParameter.getFullYear() === today.getFullYear();
}
function checkMonth(dateString) {
var enteredMS = new Date(dateString).getTime();
var currentMS = new Date().getTime();
var twoMonthMS = new Date(new Date().setMonth(new Date().getMonth() + 2)).getTime();
if (enteredMS >= twoMonthMS) {
return true;
}
return false;
}
function checkDate(day, month, year) {
//alert(browserName)
var regd = new RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})\$");
var date = month + "/" + day + "/" + year;
var date = new Date(date);
var today = new Date();
var vdob = regd.test(date);
var err_txt = "";
//alert(browserName)
var sta = isToday(new Date(date));
if (sta === true) {
return true;
}
var futdt = checkMonth(date);
if (futdt === true) {
err_txt += ("Please select a before two months Date.\n")
$("#selectdate").next('.validation').hide();
$("#selectdate").after("<div class='validation' style='color:red;margin-bottom: 20px;text-align:center;'><b>Policy start date cannot be more than 60 days</b></div>");
e.preventDefault();
}
if (date.getDate() != day || (date.getTime() < today.getTime())) {
err_txt += ("Please select a valid Date.\n")
$("#selectdate").next('.validation').hide();
$("#selectdate").after("<div class='validation' style='color:red;margin-bottom: 20px;text-align:center;'><b>Please select a valid Date</b></div>");
e.preventDefault();
}
return (err_txt);
}