1 function isValidateDate(date) {
2 date = $.trim(date);
3 var reg = /^(\d{4})-(\d{2})-(\d{2})$/;
4 reg.exec(date);
5 if (!reg.test(date) && RegExp.$2 <= 12 && RegExp.$3 <= 31) {
6 return false;
7 }
8 var year, month, day;
9 year = parseInt(date.split("-")[0], 10);
10 mOnth= parseInt(date.split("-")[1], 10);
11 day = parseInt(date.split("-")[2], 10);
12 if (! ((1 <= month) && (12 >= month) && (31 >= day) && (1 <= day))) {
13 return false;
14 }
15 if ((month <= 7) && ((month % 2) == 0) && (day >= 31)) {
16 return false;
17 }
18 if ((month >= 8) && ((month % 2) == 1) && (day >= 31)) {
19 return false;
20 }
21 if (mOnth== 2) {
22 if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))) {
23 if (day > 29) {
24 return false;
25 }
26 } else {
27 if (day > 28) {
28 return false;
29 }
30 }
31 }
32 return true;
33 }