15,846,211 members
See more:
Hi Friends,

I am having two drop down lists one is start date and second one is end date
in the drop down list i am having years.Now i want to validate that end date should always greater than start date.i.e when i selected an year 2000 in the start date and if i select year less than 2000 in the second end drop down it should show an validation message.

Thanks
Priya
Posted
Updated 30-Oct-17 7:25am

## Solution 1

http://www.w3schools.com/aspnet/control_comparevalidator.asp[^]

Check the Operator and Type Property

v2
Vani Kulkarni 26-Jun-12 0:32am

## Solution 3

Try this:
C#
```function DateCheck()
{
var StartDate= document.getElementById('txtStartDate').value;
var EndDate= document.getElementById('txtEndDate').value;
var eDate = new Date(EndDate);
var sDate = new Date(StartDate);
if(StartDate!= '' && StartDate!= '' && sDate> eDate)
{
alert("Please ensure that the End Date is greater than or equal to the Start Date.");
return false;
}
}```

end date greater than start date - jquery validation[^]
Validation of Date using JavaScript[^]
JavaScript - Date Validation - Check End Date is greater than Start Date[^]
start date and end date validation in javascript[^]

Start Date and End Date Validation[^]

## Solution 4

C#
```function ValidateEndDate() {
var startDate = \$("txtfromdate").val();
var endDate = \$("txttodate").val();
if (startDate != '' && endDate !='') {
if (Date.parse(startDate) > Date.parse(endDate)) {
\$("txttodate").val('');
alert("Start date should not be greater than end date");
}
}
return false;
}```

anurag19289 8-Nov-13 12:08pm
good1

## Solution 2

Hi,

You can call a javacript function in "onchage" of the 2nd dropdown.

First of all register both the dropdowns with hidden fields in the page load like
C#
`Page.RegisterHiddenField("hidden field name", dropdownid.ClientID);`

Then in the javascript, get the value of both the dropdowns like
JavaScript
`document.getElementById(document.getElementById("hiddenfieldname").value).value`

Then check appropriately as you want, like
if(value of 1st dropdwn < value of 2nd drop down), show a message like

Happy Coding :)

v2
priya0143 27-Jun-12 0:31am
Thank you Mohammed Mitwalli,
I don't want alert boxes.I want a validation message right to the drop down list