Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Team

I have checkboxfor, but in some moments it does not work well. What i want when i check, must populate the calendar with datepicker that has time. Below this is what i have tried

What I have tried:

HTML
<pre> <div class="form-check">
                                <div class="col-xl-2">
                                    @Html.CheckBoxFor(model => model.Lockuntil, new { @class = "form-check-input" })
                                    <label class="form-check-label" for="@Html.IdFor(model=>model.Lockuntil)">Lockuntil</label>

                                </div>
                            </div>

$( "#datepicker" ).datepicker({
      regional: "da",
      constrainInput: true,
      showWeek: true
});

$("#dataLocker").change(function() {
    if(this.checked) {
        $("#datepicker").prop("disabled",false);
    }else{
        $("#datepicker").prop("disabled",true);
    }
});
Posted
Comments
Sandeep Mewara 21-Aug-20 13:51pm    
1. What do you mean by 'does not work well'
2. Where is checkbox based HTML?
3. What exactly you are trying on click of the checkbox? Populate datepicker with datetime and show?
Jin Vincent Necesario 21-Aug-20 23:13pm    
Is the element #dataLocker a dynamic element?
If yes, you can try: $("body").on("click", "#dataLocker", function() { ... });
gcogco10 25-Aug-20 5:39am    
Hi All sorry for late, responce. what i want here. is when a user click on the checkbox it must call datepicker that has latest date and time, below the checkbox. hope make sense.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900