How a Datetype value of a text box is passed as function parameter. <TR valign="baseline"> <TD nowrap align="left">Offering Start Date: *</TD> <TD><INPUT name="OfferingStartDate" readonly type="text" id="OfferingStartDate" class="inputbox" onfocus="scwShow (scwID('OfferingStartDate') , this);" onBlur="CheckValidDate(this.id)> </TD> </TR> When the ONFOCUS event is occured ,The SCWSHOW(), shows a calender. On selecting a Date from the calender I have to call "CheckValidDate(). a javascript function with the selected Date as a parameter.TO evaluate whether the entered Date is occuring before or after the current Date(system Date). I am trying with the following code. function CheckValidDate(e) { var EntredDate=document.getElementById(e).value ; var CurrentDate = new Date(); if(EntredDate.getYear() < CurrentDate.getYear()) { alert("INVALID OFFRING DATE!"); } elseif( CurrentDate.getYear() == EntredDate.getYear() && CurrentDate.getMonth()>EntredDate.getMonth()) { alert("INVALID OFFRING DATE!"); } elseif(CurrentDate.getMonth() == EntredDate.getMonth() && CurrentDate.getDate() > EntredDate.getDate()) { alert("INVALID OFFRING DATE!"); document.write(e.getMonth()); } If any one knows the currect solution of this problem ,please reply thanks in advance
the onblur event occurs only when the text field lost his focus, if you want to validate it it after any date change, use the onchange event.