thanx for u r help…this problem is get solved..
my next problem is that there is two input text field named due_date1 and due_date2..
The due_date2 will always be greater than due_date1..and the format will be dd/mm/yyyy.
if the user enter greater date in due_date1..it displays error and clear the field.
there will be no restriction of any present..past and future dates..it simply accepts date in dd/mm/yyyy format.
below script is working..but the problem is that it doesnot accept future date.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“
<html lang=”en”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<meta name=”Content-Script-Type” content=”text/javascript”>
<meta name=”Content-Style-Type” content=”text/css”>
<title>Example</title>
<script type=”text/javascript”>
<!–
Date.prototype.toDDMMYYYYString = function () {return isNaN (this) ? ‘NaN’ : [this.getDate() > 9 ? this.getDate() : ‘0’ + this.getDate(), this.getMonth() > 8 ? this.getMonth() + 1 : ‘0’ + (this.getMonth() + 1), this.getFullYear()].join(‘/’)}
Date.fromDDMMYYYY = function (s) {return (/^(dd?)D(dd?)D(d{4})$/).test(s) ? new Date(RegExp.$3, RegExp.$2 – 1, RegExp.$1) : new Date (s)}
String.prototype.isDate = function () {return this == Date.fromDDMMYYYY(this).toDDMMYYYYString()}
// –>
</script>
<style type=”text/css”>
<!–
fieldset {padding:1ex; width:10em}
label {display:block; margin:1em 0}
input {display:block}
button {display:block; margin:auto}
–>
</style>
</head>
<body>
<form action=”some-script.pl”>
<fieldset>
<legend>Example</legend>
<label>Some date in the past <input name=”past” type=”text” onchange=”if (!this.value.isDate()) {alert(); this.value = ”; this.focus()} else if (Date.fromDDMMYYYY(this.value) > new Date()) {alert(); this.value = ”; this.focus()}”></label>
<label>Some date after that <input name=”later” type=”text” onchange=”if (!this.value.isDate()) {alert(); this.value = ”; this.focus()} else if (Date.fromDDMMYYYY(this.value) < Date.fromDDMMYYYY(this.form.past.value)) {alert(); this.value = ”; this.focus()}”></label>
<button type=”submit”>Submit</button>
</body>
</html>