Click here to Skip to main content
15,901,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Team

I am have logic, but its not working well, meaning date-picker is not a function. I want when a user first check using checkbox. It must prompt him straight to a datepicker, when unchecked it this should be hidden up until he she locks the datetime period.

What I have tried:

<div class="form-group row">
                    <div class="col-sm-6">
                        @Html.EditorFor(model => model.ModuleName, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "ModuleName" } })
                    <hr />
                <div class="form-group row">
                    <div class="col-sm-2">
                        @Html.CheckBoxFor(model => model.Lockuntil, new { @class = "rb", data_toggle = "hide-element", data_target = "#datepicker" })
                        <input id="date" type="text" /><br />
                        <input type="checkbox" id="chkDisable" onclick="disableDP()">

                <!--Jquery for datechecking-->
                <script type="text/javascript">
        dateFormat: 'dd-mm-yy',
        altField: '#thealtdate',
        altFormat: 'dd-mm-yyyy'

function disableDP(){
	$("#date").attr("disabled",  $("#chkDisable").is(":checked")).val("28-09-2020");
Sandeep Mewara 28-Sep-20 6:56am    
And the issue is?
gcogco10 28-Sep-20 7:51am    
datepicker is not working.
ZurdoDev 28-Sep-20 10:37am    
That tells us nothing useful.
bbirajdar 28-Sep-20 11:05am    
Check the errors in browser console. Something is breaking the client side script.
Jin Vincent Necesario 8-Oct-20 10:10am    
Maybe, you just need to enclose your statement properly, it seems you forgot to enclose your statement with a closing-parenthesis.
From this:
"$("#date").attr("disabled", $("#chkDisable").is(":checked")).val("28-09-2020");"
"$("#date").attr("disabled", $("#chkDisable").is(":checked")).val("28-09-2020"));".

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