RunTime Error: Microsoft JScript runtime error: 'ValidateDate' is undefined

Last post 11-13-2009 2:59 AM by Vince Xu - MSFT. 3 replies.

Sort Posts:

  • RunTime Error: Microsoft JScript runtime error: 'ValidateDate' is undefined

    11-11-2009, 1:06 AM

    Im getting above runtime error on 

    OnClientDateSelectionChanged="ValidateDate" of CalendarExtender

    Code:

    <%

    <%

    @ Page Language="C#" AutoEventWireup="true" CodeFile="AjaxCalender.aspx.cs" Inherits="AjaxCalender" Theme="KSTheme"%>@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"

    TagPrefix

    ="cc1" %>

    <!

    <

    <

    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">html xmlns="http://www.w3.org/1999/xhtml">head runat="server">

     

     

    <script type="text/javascript">

     

    function

    {

     

     

     

    dateTo.enble =

     

     

     

     

     

    dateFrom.enable =

    }

    }

    ValidateDate(sender,args) var dateTo = document.getElementById("txtDateTo")if (dateTo.enable==true) {false;var dateFrom = document.getElementById("txtDateFrom")if (dateFrom.enable==true) {false;

    function

    {

     

    {

    alert(

    sender._selectedDate =

     

    CheckDateEalier(sender,args) if (sender._selectedDate < new Date()) "You cannot select a day before today!");new Date();// set the date back to the today

    sender._textbox.set_Value(sender._selectedDate.format(sender._format))

    }

    }

    </

    script>

     

    <title></title>

     

    </

    <

    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />head>body>

     

    <form id="form1" runat="server">

     

    <div>

     

    <asp:ScriptManager ID="asm" runat="server" />

     

    <div>

     

    <table>

     

    <tr>

     

    <td width="100" >

     

    <asp:Label ID="lblDateFrom" Text="Date From:" runat="server"></asp:Label>

     

    </td>

     

    <td>

     

    <asp:TextBox ID="txtDateFrom" runat="server" />

     

    <asp:Image ID="btnCallCalc" runat="server" ImageUrl="~/Images/CalendarIcon.png" />

     

    </td>

     

    <cc1:CalendarExtender ID="CalendarExtender1" TargetControlID="txtDateFrom" PopupButtonID="btnCallCalc" PopupPosition="TopRight" runat="server"

     

    OnClientDateSelectionChanged="ValidateDate"

     

    ></cc1:CalendarExtender>

     

    <td></td>

     

    <td width="100" >

     

    <asp:Label ID="lblDate_To" Text="Date To:" runat="server"></asp:Label>

     

    </td>

     

    <td><asp:TextBox ID="txtDateTo" runat="server" />

     

    <asp:Image ID="btnOpenCalc" runat="server" ImageUrl="~/Images/CalendarIcon.png" />

     

    <cc1:CalendarExtender ID="calenderEx" TargetControlID="txtDateTo" PopupButtonID="btnOpenCalc" runat="server"></cc1:CalendarExtender>

     

    </td>

     

    </tr>

     

    </

    </table>div>

     

     

     

    </div>

     

    </

    </

    </form>body>html>

  • Re: RunTime Error: Microsoft JScript runtime error: 'ValidateDate' is undefined

    11-11-2009, 3:22 AM
    • Contributor
      3,674 point Contributor
    • stanly
    • Member since 02-09-2009, 9:35 AM
    • Chennai
    • Posts 878

    here i'm checking with today's date... check this...

    <script type="text/javascript">

            function checkDate(sender, args) {
                if (sender._selectedDate < new Date()) {
                    alert("You cannot select a day earlier than today!");
                    sender._selectedDate = new Date();
                    // set the date back to the current date
                   sender._textbox.set_Value(sender._selectedDate.format(sender._format))
                     //var text=document.getElementById('txtClosingDate');
                     //text.value=null;
                }
            }

        </script>


    <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtOpenDate"
            OnClientDateSelectionChanged="checkDate" PopupPosition="Right" PopupButtonID="Image3">
                    </cc1:CalendarExtender>


    call check date function in OnClientDateSelectionChanged event



    stanly Stanly

    Follow me on Twitter
    My Blog
    If this post was useful to you, please mark it as answer
  • Re: RunTime Error: Microsoft JScript runtime error: 'ValidateDate' is undefined

    11-11-2009, 4:41 AM

    Im also calling the required function in OnClientDateSelectionChange event 

    But it throwing error in running the project that runtime error related to Microsoft JScript runtime.

    It is not linked with funtion code as also tried with simple funtion with only alert actually it is not entertaining any funtion on this event.

  • Re: RunTime Error: Microsoft JScript runtime error: 'ValidateDate' is undefined

    11-13-2009, 2:59 AM
    Answer

    Hi,

    If you define OnClientDateSelection event "OnClientDateSelection='ValidateDate'", you can define the javascript function in the tail of the html page.

    function ValidateDate(arg,e)
    {
        //
    }

     


    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (4 items)