Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 473.2k

How to checked your datepicker in jquery using bootstrap?

Aug 26 2020 3:49 AM
Hi Team
 
I have this Razor @html.CheckboxFor(model=>model.LockUntil), i want this when i check it must bring datepicker for current month, time. This is what i have done below, its not working and there are no errors when i inspect.
  1. <div class="form-check">  
  2.                               <div class="col-xl-2">  
  3.                                   @Html.CheckBoxFor(model=>model.Lockuntil, new { htmlAttributes = new { @class = "form-control"id="checkbox" } })  
  4.                                   <label class="form-check-label" for="@Html.IdFor(model=>model.Lockuntil)">Lockuntil</label>  
  5.                                     
  6.   
  7.                               </div>  
  8.                                
  9.                           </div>  
  10.   
  11.                 
  12.                           @section srcipts{  
  13.                               <script src="~/Scripts/jquery-ui-1.12.1.min.js"></script>  
  14.                              <script type="text/javascript">  
  15.                           $('#checkbox').change(function(){  
  16.               if($(this).is(':checked')){  
  17.       $( "#from" ).datepicker('setDate', new Date(2020, 08, 26)).datepicker( "option", "disabled", true );  
  18.       }else{  
  19.       $( "#to" ).datepicker( "option", "disabled", false);  
  20.        
  21.        }  
  22.         });  
  23.         });  
  24.                             </script>  
  25.                                 
  26.                               }  
 

Answers (2)