//+---------------------------------------------------
//| Validation of date legitimacy
//| Format: YYYY-MM-DD or YYYY/MM/DD
//+---------------------------------------------------
function Isvaliddate (DATESTR)
{
var sdate=datestr.replace (/(^\s+|\s+$)/g, '); Go on both sides of the space;
if (sdate== ") return true;
If the format satisfies yyyy-(/) mm-(/) DD or yyyy-(/) m (/) DD or yyyy-(/) m (/) d or yyyy-(/) mm-(/) d is replaced by "
In the database, the legal date can be: Yyyy-mm/dd (2003-3/21), the database is automatically converted to the YYYY-MM-DD format
var s = sdate.replace (/[\d]{}[\-/]{1}[\d]{}[\-/]{1}[\d]{}/g, ');
if (s== ')//description format satisfies YYYY-MM-DD or YYYY-M-DD or yyyy-m-d or yyyy-mm-d
{
var t=new Date (Sdate.replace (/\-/g, '/'));
var ar = sdate.split (/[-/:]/);
if (ar[0]! = t.getyear () | | ar[1]! = T.getmonth () +1 | | ar[2]! = T.getdate ())
{
Alert (' Wrong date format! The format is: Yyyy-mm-dd or YYYY/MM/DD. Note leap years. ‘);
return false;
}
}
Else
{
Alert (' Wrong date format! The format is: Yyyy-mm-dd or YYYY/MM/DD. Note leap years. ‘);
return false;
}
return true;
}
Date legitimacy Verification (format: YYYY-MM-DD or YYYY/MM/DD)