retrieve id of textbox from content place holder in jquery function
<p>I am using JQUERY UI for my web pages. I am trying to use datepicker control. The problem is jquery function is not taking the textbox ID. It is working when I concatenate the content placeholder id with textbox id. </p>

<pre><code>&lt;asp:Content ID="PassportContent" ContentPlaceHolderID="CPH001" runat="server"&gt;
&lt;div class="form-group"&gt;
    &lt;label&gt;Date Of Birth&lt;/label&gt;
    &lt;asp:TextBox ID="datepicker" runat="server" CssClass="txt-control"&gt;&lt;/asp:TextBox&gt;
&lt;/div&gt;
&lt;/asp:Content&gt;
</code></pre>

<p><strong>actual jquery code</strong> </p>

<pre><code>&lt;script src="../jquery/external/jquery/jquery.js"&gt;&lt;/script&gt;
&lt;script src="../jquery/jquery-ui.min.js"&gt;&lt;/script&gt; 
&lt;script&gt;
    $(function () {
        $("#datepicker").datepicker();
    });
&lt;/script&gt;
</code></pre>

<p><strong>working jquery code</strong> </p>

<pre><code>&lt;script&gt;
    $(function () {
        var temp = document.getElementById('&lt;%= datepicker.ClientID %&gt;').value;
        alert(temp);
        $("#CPH001_datepicker").datepicker();
    });
&lt;/script&gt;
</code></pre>

<p>When I searched in forums most of the solutions suggested to use <code>document.getElementById</code>, I tried getting the ID using >></p>

<p><code>document.getElementById('&lt;%= datepicker.ClientID %&gt;').value</code>; but the alert box is showing NULL.</p>

<ol>
<li>How to solve this problem?</li>
<li>When I keep my js code in seperate file, how to solve this problem ?</li>
</ol>

<p>As suggested, I used <code>$("[id$=datepicker]").datepicker();</code>. And it works I am getting the datepicker. But I cannot change the date format and restrict the date range. Please suggest. </p>

<pre><code>&lt;script&gt;
    $(function () {
        $("[id$=datepicker]").datepicker();        

        $("[id$=datepicker]").datepicker({ dateFormat: 'ISO 8601 - yy-mm-dd' }); // not working
    });
    // not working
    $("#format").change(function () { $("[id$=datepicker]").datepicker('ISO 8601 - yy-mm-dd', "dateFormat", $(this).val()); });
&lt;/script&gt;
</code></pre>