Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
after clicking calender control,, validation for that function is done and on clicking next textbox it is showing undefined in datetextbox..

following is my code....



C#
function Sdatecheck()
    {

            if (document.getElementById("<%=txtDateTo.ClientID%>").value=="")
      {
                 alert("Please Enter the Sale Date");
                 document.getElementById("<%=txtDateTo.ClientID%>").focus();
                 return false;
      }

     var gndate = document.getElementById("<%=txtDateTo.ClientID%>").value.split("/");
     var m_names = new Array("Jan", "Feb", "Mar",
"Apr", "May", "Jun", "Jul", "Aug", "Sep",
"Oct", "Nov", "Dec");
     var usedate=new Date(gndate[2],gndate[1]-1,gndate[0]);
     var today=new Date();
     var td=today.getDate();
     var gd=usedate.getDate();
     if(td==gd)
     {
     }
     else if(usedate<today)
     {
     alert("Invalid Sale Date!Enter present or future Date");
     document.getElementById("<%=txtDateTo.ClientID%>").focus();
     return false;
     }
      document.getElementById("<%=txtDateTo.ClientID%>").value = m_names[gndate[1]-1] +gndate[0];

     }
Posted

1 solution

VB
document.getElementById("<%=txtDateTo.ClientID%>").value=="")


Are you using jsp scriplet in javascript? jsp scriplet only works in jsp. Pass this id as parameter in Sdatecheck(var id) from jsp page ,then it will work. like :
Java
onclick="Sdatecheck('<%=txtDateTo.ClientID%>')"
 
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