简体   繁体   中英

jquery datepicker not popping up?

i get these errors from IE7:

Line 22: object doesnt support this property or method line 142: invalid argument

i am trying to do a datepicker on a textbox:

    <script>
        jQuery(function($) {
       $("#<%= report_dateTextBox.ClientID %>").mask("99/99/9999");
$("#<%= occurrence_dateTextBox.ClientID %>").datepicker();
    });

here's the textbox:

<asp:TextBox ID="occurrence_dateTextBox" runat="server" size="50"/>

here's the complete code:

http://pastebin.com/Z08r6vMp

the .mask worked fine before i added the datepicker , but neither work now.

what am i doing wrong?

as TT. suggested i changed it to this:

jQuery(function($) {
        //$("#occurrence_dateTextBox").mask("99/99/9999");
        //$("#<%= report_dateTextBox.ClientID %>").mask("99/99/9999");
        //$("#<%= occurrence_dateTextBox.ClientID %>").datepicker();
        $(".datepicker").datepicker(); 

    });

and

  <asp:TextBox ID="occurrence_dateTextBox" runat="server" size="50" class="datepicker"/>

and still does not work

occurence_dateTextBox is the server ID of the control, you need the client side ID. You should also need to do the same for report_dateTextBox . I'm not sure how that was working before.

Try

$("#<%= report_dateTextBox.ClientID %>").mask("99/99/9999");
$("#<%= occurrence_dateTextBox.ClientID %>").datepicker();

Update

Here is a simplified version of your page. Any code that is not necesary has been removed.

Notice that your old version includes multiple versions of jQuery, one from Googles CDN and another locally. Now it pulls jQuery and the UI from the CDN.

You can copy and paste this into a new .aspx page and it will work.

On your own version, I suggest using Firefox and Firebug and just looking at the console to get the exact error message, because it is coming from something else other than the following code. You might not be pulling jQuery UI properly, or one of your other javascript calls is broken and it is causing problems with the datepicker.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" %>
<!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 id="Head1" runat="server">
    <title></title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js" type="text/javascript"></script>
    <script>

        jQuery(function($) {
            //$("#occurrence_dateTextBox").mask("99/99/9999");
            //$("#<%= report_dateTextBox.ClientID %>").mask("99/99/9999");
            $("#<%= occurrence_dateTextBox.ClientID %>").datepicker();
            //$(".datepicker").datepicker(); 

        });

    </script>
</head>
<body><div id="container">
    <form id="form1" runat="server" class="niceform">

        <fieldset>

        <legend>Section A</legend>

        <dl>

            <dt><label for="occurrence_dateTextBox" class="datepicker">Occurrence Date:</label></dt>
            <dd><asp:TextBox ID="occurrence_dateTextBox" runat="server" size="50"/></dd>
        </dl>

        <dl>

            <dt><label for="report_dateTextBox">Report Date:</label></dt>
            <dd><asp:TextBox ID="report_dateTextBox" runat="server" size="50"/></dd>
        </dl>

        </fieldset>       

        <asp:Button ID="Button1" runat="server" Text="Button" />


    </form>
</div></body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM