Click to See Complete Forum and Search --> : Help with date validation


hexchad
07-06-2009, 10:19 PM
Hi gurus,

I had copied a date validation below where i used in my page. unfortunately, i lost my notebook. the last backup i had was not updated... please help/correct the jscript i have to make it usuable again. i have an input box for date.

I need to validate a date input and return "Invalid date" if the format is not correct.

Thanks in advance.

code:

<script type="text/javascript">

Date.prototype.toDateString = function () {return isNaN (this.getDate()) ? 'Invalid date' : [this.getMonth() < 9 ? '0' + (this.getMonth() + 1) : this.getMonth() + 1, this.getDate() < 10 ? '0' + this.getDate() : this.getDate(), this.getFullYear()].join ('/')}

</script>

<input name="tdate" type="text" maxlength="10" size="11" value="" />