The below code is used to validate start and end date(two textbox and date is selected from calendar)when a button is clicked.The code works fine.The problem is i have 8 more start and end date to validate.so can anyone tell me a common code to validate all the start and end date because of the code length.
function validated() {
var cal1=document.getElementById('<%=EndDateTwo.ClientId%>').value;
var cal2= document.getElementById('<%=StartDateTwo.ClientId%>').value;
if (cal1 == '' || cal2 == '') {
alert("Start Date and 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 the Start date ");
return false;
}
return true;
I am using html button to call this
<asp:Button ID="Button2" OnClientClick="return validated();" runat="server" Text="Enable" />