Hi,
First of all i found one issue with your last if statement, your code for checking
fromDate > toDate is incorrect. it will give you incorrect result.
The only way to get it right is to change your Date format. Convert your date in form of
yyyyMMdd and then comparison like a numeric value will be fine. But you are directly matching your date from textbox and i don't think user will insert date in yyyyMMdd format.
One more change,
if (fromDate == "" && toDate == "")
{
alert("from & To date Should not be Empty");
}
if (fromDate != "" && toDate == "") {
alert("Please enter to Date");
}
can be changed with below code if you do not need to specify which date is empty. Or you can also add RequiredField Validator in your textbox(Only if you are working in ASP.NET).
if (fromDate == "" || toDate == "")
{
alert("from Or To date Should not be Empty");
}
Second, you can not use Swith case with range either in javascript or in C# code. Check Answer in
this[
^] discussion.
Thanks
-Amit Gajjar