asp.net - how to validate multiple textbox for date using javascript -
the below code used validate start , end date(two textbox , date selected calendar)when button clicked.the code works fine.the problem have 8 more start , end date validate.so can tell me common code validate start , end date because of code length.
function validated() { var cal1=document.getelementbyid('<%=enddatetwo.clientid%>').value; var cal2= document.getelementbyid('<%=startdatetwo.clientid%>').value; if (cal1 == '' || cal2 == '') { alert("start date , end date can not bleft blank."); return false; } var dt1 = date.parse(cal1); var dt2 = date.parse(cal2); if (dt1 <= dt2) { alert("end date must occur after start date "); return false; } return true;
i using html button call this
<asp:button id="button2" onclientclick="return validated();" runat="server" text="enable" />
you create method validate(cal1, cal2)
call each date pair wan tto validate within validate()
method
Comments
Post a Comment