Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>See below. The main function is isDate to which you can pass day, month and year. These are javascript functions, so it alerts a relevant message and returns false.</p> <p>The daysInFebruary will calculate the number of days for feb for the year passed.</p> <p>The DaysArray keeps an array of the number of days for each month.</p> <pre><code>var minYear=1900; var maxYear=2100; function daysInFebruary (year){ // February has 29 days in any year evenly divisible by four, // EXCEPT for centurial years which are not also divisible by 400. return (((year % 4 == 0) &amp;&amp; ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); } function DaysArray(n) { for (var i = 1; i &lt;= n; i++) { this[i] = 31 if (i==4 || i==6 || i==9 || i==11) {this[i] = 30} if (i==2) {this[i] = 29} } return this } function isDate(strDay,strMonth,strYear ){ var daysInMonth = DaysArray(12) if (strDay.charAt(0)=="0" &amp;&amp; strDay.length&gt;1) strDay=strDay.substring(1) if (strMonth.charAt(0)=="0" &amp;&amp; strMonth.length&gt;1) strMonth=strMonth.substring(1) for (var i = 1; i &lt;= 3; i++) { if (strYr.charAt(0)=="0" &amp;&amp; strYr.length&gt;1) strYr=strYr.substring(1) } month=parseInt(strMonth) day=parseInt(strDay) year=parseInt(strYr) if (strMonth.length&lt;1 || month&lt;1 || month&gt;12){ alert("Please enter a valid month") return false } if (strDay.length&lt;1 || day&lt;1 || day&gt;31 || (month==2 &amp;&amp; day&gt;daysInFebruary(year)) || day &gt; daysInMonth[month]){ alert("Please enter a valid day") return false } if (strYear.length != 4 || year==0 || year&lt;minYear || year&gt;maxYear){ alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear) return false } return true } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload