title: Prevent users from entering date in textbox which is blocked in Calendar ASP
body: <p>I have a textbox which has a calendar icon at its right side. When I click icon, the calendar appears which allows user to select a particular date. In calendar the user cannot select the previous date and also the calendar is blocked for 2 years from the current date.</p>
  
  <p>Now I have to validate the textbox. </p>
  
  <ol>
  <li>If user manually enters any past date it gives an error " Invalid
  Date" - which is correct </li>
  <li>But if the user enters future date i.e, a
  date after 2 years from current date, the system accepts which is
  incorrect.</li>
  </ol>
  
  <p>So I want to validate textbox so that user gets an error "Invalid Date" if he enters a date now available in calendar and I don't want Read Only textbox.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      window.onload = function () {
          var dateToday = new Date();
          $("input.dtpRelease").datepicker({
  
              showOn: 'button',
              changeYear: true,
              changeMonth:true,
              minDate: dateToday,
              maxDate: "2y",
              buttonImageOnly: true,
              dateFormat: "mm/dd/yy",
              buttonImage: '/Images/icon_calendar_24.png',
  
          });
     }
  
  &lt;asp:TextBox ID="dtpStartDate" runat="server" Style="width: 80px; margin-top: 5px;" CssClass="form-control dp2 dtpRelease pull-left" MaxLength="100" placeholder="Start Date" Text='&lt;%# MSEncoder.Encoder.HtmlEncode(Convert.ToString( Eval("FulfillmentStartDate"))) %&gt;' onblur="ValidateDate(this)"&gt;&lt;/asp:TextBox&gt; 
                             &lt;br/&gt;&lt;br/&gt;&lt;asp:RegularExpressionValidator ID="regExSDate" runat="server" ControlToValidate="dtpStartDate" ForeColor="Red" Display="Dynamic" ValidationExpression="^(((0?[1-9]|1[012])/(0?[1-9]|1\d|2[0-8])|(0?[13456789]|1[012])/(29|30)|(0?[13578]|1[02])/31)/(19|[2-9]\d)\d{2}|0?2/29/((19|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00)))$" ErrorMessage="Please enter date in MM/DD/YYYY Format"  ValidationGroup="vg" &gt;&lt;/asp:RegularExpressionValidator&gt;
                                       &lt;asp:CompareValidator ID="cvStartDate" runat="server" ControlToValidate="dtpStartDate" ErrorMessage="Invalid Start Date" ForeColor="Red" Operator="GreaterThanEqual"  Display="Dynamic" ValidationGroup="FirstPreview" CssClass="validatorMsg" ValueToCompare="&lt;%# DateTime.Today.ToShortDateString() %&gt;" SetFocusOnError="True"  Type="Date" &gt;&lt;/asp:CompareValidator&gt; 
  </code></pre>