Check for Valid Date using JavaScript

Check for valid date using JavaScript. below is the full code.
  1. <head id="Head1" runat="server">  
  2.     <title>Untitled Page</title>  
  3.     <script language="javascript" type="text/javascript">  
  4.     // Declaring valid date character, minimum year and maximum year  
  5.     var dtCh = "/";  
  6.     var minYear = 1900;  
  7.     var maxYear = 2100;  
  8.   
  9.     function isInteger(s) {  
  10.         var i;  
  11.         for (i = 0; i < s.length; i++) {  
  12.             // Check that current character is number.  
  13.             var c = s.charAt(i);  
  14.             if (((c < "0") || (c > "9"))) return false;  
  15.         }  
  16.         // All characters are numbers.  
  17.         return true;  
  18.     }  
  19.   
  20.     function stripCharsInBag(s, bag) {  
  21.         var i;  
  22.         var returnString = "";  
  23.         // Search through string's characters one by one.  
  24.   
  25.         // If character is not in bag, append to returnString.  
  26.         for (i = 0; i < s.length; i++) {  
  27.             var c = s.charAt(i);  
  28.             if (bag.indexOf(c) == -1) returnString += c;  
  29.         }  
  30.         return returnString;  
  31.     }  
  32.   
  33.     function daysInFebruary(year) {  
  34.         // February has 29 days in any year evenly divisible by four,  
  35.         // EXCEPT for centurial years which are not also divisible by 400.  
  36.         return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28);  
  37.     }  
  38.   
  39.     function DaysArray(n) {  
  40.         for (var i = 1; i <= n; i++) {  
  41.             this[i] = 31  
  42.             if (i == 4 || i == 6 || i == 9 || i == 11) { this[i] = 30 }  
  43.             if (i == 2) { this[i] = 29 }  
  44.         }  
  45.         return this  
  46.     }  
  47.   
  48.     function isDate(dtStr) {  
  49.         var daysInMonth = DaysArray(12)  
  50.         var pos1 = dtStr.indexOf(dtCh)  
  51.         var pos2 = dtStr.indexOf(dtCh, pos1 + 1)  
  52.         var strMonth = dtStr.substring(0, pos1)  
  53.         var strDay = dtStr.substring(pos1 + 1, pos2)  
  54.         var strYear = dtStr.substring(pos2 + 1)  
  55.         strYr = strYear  
  56.         if (strDay.charAt(0) == "0" && strDay.length > 1)  
  57.             strDaystrDay = strDay.substring(1)  
  58.         if (strMonth.charAt(0) == "0" && strMonth.length > 1)  
  59.             strMonthstrMonth = strMonth.substring(1)  
  60.         for (var i = 1; i <= 3; i++) {  
  61.             if (strYr.charAt(0) == "0" && strYr.length > 1)  
  62.                 strYrstrYr = strYr.substring(1)  
  63.         }  
  64.         month = parseInt(strMonth)  
  65.   
  66.         day = parseInt(strDay)  
  67.         year = parseInt(strYr)  
  68.         if (pos1 == -1 || pos2 == -1) {  
  69.             alert("The date format should be : mm/dd/yyyy")  
  70.             return false  
  71.         }  
  72.         if (strMonth.length < 1 || month < 1 || month > 12) {  
  73.             alert("Please enter a valid month")  
  74.             return false  
  75.         }  
  76.         if (strDay.length < 1 || day < 1 || day > 31 || (month == 2 && day > daysInFebruary(year)) || day > daysInMonth[month]) {  
  77.             alert("Please enter a valid day")  
  78.             return false  
  79.         }  
  80.         if (strYear.length != 4 || year == 0 || year < minYear || year > maxYear) {  
  81.             alert("Please enter a valid 4 digit year between " + minYear + " and " + maxYear)  
  82.             return false  
  83.         }  
  84.         if (dtStr.indexOf(dtCh, pos2 + 1) != -1 || isInteger(stripCharsInBag(dtStr, dtCh)) == false) {  
  85.             alert("Please enter a valid date")  
  86.             return false  
  87.         }  
  88.         return true  
  89.     }  
  90.   
  91.     function ValidateForm() {  
  92.         var dt;  
  93.         dt = document.getElementById('txtDate');  
  94.         if (isDate(dt.value) == false) {  
  95.             dt.focus()  
  96.             return false  
  97.         }  
  98.         return true  
  99.     }  
  100.     </script>  
  101. </head>  
  102.   
  103. <body>  
  104.     <form id="form2" runat="server">  
  105.         <div>  
  106.             <asp:TextBox ID="txtDate" runat="server">  
  107.             </asp:TextBox>  
  108.             <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="ValidateForm()" />  
  109.         </div>  
  110.     </form>  
  111. </body>