I am looking for a textbox that a user can enter an expiration date for his/her license. The user can only enter an expiration date that is between today's date and up to 12/31/2099.

This is what I have now:

function RangeValidation(dt)
        {
            var startrange = new Date(Date.parse("12/02/1900"));
            var endrange = new Date(Date.parse("12/31/2099"));
            var lblmesg = document.getElementById("<%=lblMesg.ClientID%>") ;
            if (dt<startrange || dt>endrange)
            {
                lblmesg.style.color="red";
                lblmesg.innerHTML = "Date should be between 12/01/2014 and 12/31/2099";
            }
        }

    <asp:TextBox ID="txtRange" runat="server" MaxLength = "10" onkeyup = "ValidateDate(this, event.keyCode)" onkeydown = "return DateFormat(this, event.keyCode)"></asp:TextBox>

Is there an easier way to do that? I am running into date issues, for exampele dd/mm/yyyy and so on, I would like something simple in ASP.Net (I don't prefer using JavaScript cause I am not familiar with it)

Thanks.

Related posts

Recent Viewed