// Checks if a given date string is in 
// one of the valid formats:
// a) M/D/YYYY format
// b) M-D-YYYY format
// c) M.D.YYYY format
// d) M_D_YYYY format
function isDate(s)
{   
	// make sure it is in the expected format
	if (s.search(/^\d{1,2}[\/|\-|\.|_]\d{1,2}[\/|\-|\.|_]\d{2,4}/g) != 0)
		return false;
	// remove other separators that are not valid with the Date class 			
	s = s.replace(/[\-|\.|_]/g, "/");
			
	// convert it into a date instance
    var dt = new Date(Date.parse(s));	    

    // check the components of the date
    // since Date instance automatically rolls over each component
    var arrDateParts = s.split("/");
    return (
        dt.getMonth() == arrDateParts[0]-1 &&
        dt.getDate() == arrDateParts[1]
 //       && dt.getFullYear() == arrDateParts[2]	// this fails for yy year
	);			
}
