function ValidateDate(txt, keyCode) { if(keyCode==16) isShift = false; var val=txt.value; var lblmesg = document.getElementById("<%=lblMesg.ClientID%>") ; if(val.length == 10) { var splits = val.split("/"); var dt = new Date(splits[1] + "/" + splits[0] + "/" + splits[2]); //Validation for Dates if(dt.getDate()==splits[0] && dt.getMonth()+1==splits[1] && dt.getFullYear()==splits[2]) { lblmesg.style.color="green"; lblmesg.innerHTML = "Valid Date"; } else { lblmesg.style.color="red"; lblmesg.innerHTML = "InValid Date"; return; } //Range Validation if(txt.id.indexOf("txtRange") != -1) RangeValidation(dt); //BirthDate Validation if(txt.id.indexOf("txtBirthDate") != -1) BirthDateValidation(dt) } else if(val.length < 10) { lblmesg.style.color="blue"; lblmesg.innerHTML = "Required dd/mm/yy format. Slashes will come up automatically."; } }
<asp:TextBox ID="txtValidate" runat="server" MaxLength = "10" onkeyup = "ValidateDate(this, event.keyCode)" onkeydown = "return DateFormat(this, event.keyCode)"></asp:TextBox> I want to include a slash within a TextBox for typing a Date.. I don't want it to generate a slash while typing...it should be static when the page is loaded.... Is it possible to do that without using AjaxToolkit ???
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)