Validate a dateTag(s): Language
<HTML><HEAD> <SCRIPT> function getYear(d) { return (d < 1000) ? d + 1900 : d; } function isDate (year, month, day) { // month argument must be in the range 1 - 12 month = month - 1; // javascript month range : 0- 11 var tempDate = new Date(year,month,day); if ( (getYear(tempDate.getYear()) == year) && (month == tempDate.getMonth()) && (day == tempDate.getDate()) ) return true; else return false } if (isDate(1997, 2, 28)) alert("1997-02-31 is valid!"); else alert("1997-02-31 is invalid!"); </SCRIPT></HEAD><BODY>test date</BODY> <HTML>
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com