Hi,
I am using the following function for the date validation. I have a textfield and a datepicker. I am calling the below finction as onBlur(). As and when i picks a wrong date it is not displaying any alert message. But if i clicks into the textfield and presses the tab button it displays the alert message.

Like this without choosing the date using datepicker if i am directly typing a wrong date and presses d tab id displays the alert message and the cursor going to datepicker box, even if i am specifying the focus() function control goes to the datepicker box . Pls help to solve this problem

Thank You
*******************
function verifyDate(sValue) { // returns false or a Date object.
var theDate = stringToDate(sValue); // your textbox value
if (!theDate) {
alert("Please enter a valid Date");
return false;
}

var minDate = new Date("Sat, 1 Jan 2006");
var maxDate = new Date("Wed, 1 Mar 2006");

if (theDate.getTime() < minDate.getTime()) {
alert("Please enter a date on or after " + minDate);
return false;
}
if (theDate.getTime() > maxDate.getTime()) {
alert("Please enter a date on or before " + maxDate);
return false;
}
return theDate;
}

function stringToDate(inStr) { // returns a date from input dd/mm/yyyy
if (!inStr) return false;
var reDate = /^\s*(\d{1,2})\D*(\d{1,2})\D*(\d{2,4})\s*$/
var matchArray = reDate.exec(inStr);
if (!matchArray) return false;
var tDay = parseInt(matchArray[1],10);
var tMonth = parseInt(matchArray[2],10);
var tYear = parseInt(matchArray[3],10);
if (isNaN(tDay + tMonth + tYear)) return false;
if (tYear.toString().length == 3) return false;
if (tYear.toString().length <= 2)
tYear += (tYear < 50) ? 2000 : 1900;
return isValidDate(tYear, tMonth - 1, tDay);
}

function isValidDate(inY,inM,inD) {
var testDate = new Date(inY, inM, inD);
if (!testDate) return false;
return ( testDate.getDate() == inD
&& testDate.getMonth() == inM
&& testDate.getFullYear() == inY) ? testDate : false;
}
=================

This is how i am calling the function

<input name="expirydate" type="text" size="8" value="<? echo $edit_query_val['expirydate'];?>" onBlur="return verifyDate(this.value);">


Balen