Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Have two Ajax Calendar Control and Two Textbox if the first textbox date should not be less than second textbox user should enter the date must be greater date from first text box using Javascript

Pls somebody help me

Thanks in Advance
Posted

you can use this


C#
function CompareDates()
       {
            var fdate = document.getElementById('<%=txtAgValidFrom.ClientID%>');
            var edate = document.getElementById('<%=txtAgValidTo.ClientID%>');
            var FromDate = fdate.value.split('/');
            var EndDate = edate.value.split('/');
            var val = 'false';

            if (parseInt(FromDate[2]) < parseInt(EndDate[2])) {
                val = 'true';
                return true;
            }
            else if (parseInt(FromDate[2]) == parseInt(EndDate[2])) {
                if (parseInt(FromDate[0]) < parseInt(EndDate[0])) {
                    val = 'true';
                    return true;
                }
                else if (parseInt(FromDate[0]) == parseInt(EndDate[0])) {
                    if (parseInt(FromDate[1]) <= parseInt(EndDate[1])) {
                        val = 'true';
                        return true;
                    }
                }
            }
            if (val == "false") {
                alert("Agreement valid from date cannot be greater than Agreement valid to date");
                return false;
            }
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900