Note that there are some explanatory texts on larger screens.

plurals
  1. POdisable dates using jquery inside gridview control
    text
    copied!<p>I have a gridview which contains a textbox control. I need to show the calendar for the user to pick the date and certain dates are to be disabled using jquery. I found a post on stackoverflow that talked about how to disable certain dates. I am done with that part, except not sure how to pass the textbox control to this jquery function. Here is the code.</p> <pre><code>&lt;script type="text/javascript" language="javascript"&gt; function pageLoad(sender, args) { var enabledDays = ['09/21/2011', '10/05/2011', '10/19/2011', '11/02/2011', '11/16/2011']; /* utility functions */ function editDays(date) { for (var i = 0; i &lt; enabledDays.length; i++) { if (new Date(enabledDays[i]).toString() == date.toString()) { return [true]; } } return [false]; } /* create datepicker */ $(document).ready(function() { $('#&lt;%= txtInHomeDate.ClientID %&gt;').datepicker({ beforeShow: springDate, beforeShowDay: editDays, dateFormat: 'mm/dd/yy', buttonImage: 'images/cal.gif', buttonText: 'Choose date', firstDay: 1, buttonImageOnly: true, showOn: 'both', showAnim: 'fadeIn', onSelect: function() { $(this).trigger("onchange", null); } }); function springDate() { var defaultMin = new Date(); var defaultMax = new Date(); var Min = defaultMin; var Max = defaultMax; // make valid date from hiddenfied value format is MM/dd/yyyy dateMin = $('#&lt;%= hfStDate.ClientID %&gt;').val(); dateMin = new Date(dateMin); dateMax = $('#&lt;%= hfEndDate.ClientID %&gt;').val(); dateMax = new Date(dateMax); if (dateMin &amp;&amp; dateMax) { Min = new Date(dateMin.getFullYear(), dateMin.getMonth(), dateMin.getDate()); Max = new Date(dateMax.getFullYear(), dateMax.getMonth(), dateMax.getDate()); } return { minDate: Min, maxDate: Max }; } }); } </code></pre> <p></p> <p>&lt;....</p> <pre><code>&lt;asp:TemplateField HeaderText="In-Home Date"&gt; &lt;ItemStyle HorizontalAlign="Center" /&gt; &lt;ItemTemplate&gt; &lt;asp:HiddenField ID="hfStDate" runat="server" Value="09/01/2011" /&gt; &lt;asp:HiddenField ID="hfEndDate" runat="server" Value="11/30/2011" /&gt; &lt;asp:TextBox ID="txtInHomeDate" runat="server" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; </code></pre> <p>Currently, it errors out since the jquery function won't find the txtInHomeDate. Could I get some help as I am pretty close to get this done? Thanks!!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload