@felgallJul 21.2006 — #the following check for / - or . separators as well as validating a day between 1 and 31, month between 1 and 12 and year between 1900 and 2099. Leading zeros on day and month are optional.
@CharlesJul 21.2006 — #Here's a more robust way of doing things. Instead of being so rigid and unforgiving with your user we help him or her out:<script type="text/javascript"> Date.prototype.toDateString = function () {return [this.getMonth() < 9 ? '0' + (this.getMonth() + 1) : this.getMonth() + 1, this.getDate() < 10 ? '0' + this.getDate() : this.getDate(), this.getFullYear()].join('/')} </script>
<label>Date <input onchange="var d = new Date (this.value); if (isNaN (d)) {alert (''); this.value = ''; this.focus()} else {this.value = d.toDateString()}"></label>