I am using jquery ui and trying to use datepicker. It works well but if I want to set current date to the field then it does not work. I have tried some but no luck. Can anyone please help me? My attempts are below :
My input >>
<g:textField id="admissionDate" class="form-control datepicker" name="admissionDate"
required=""/>
Set date attempt on document ready >>
$("#admissionDate").datepicker({
dateFormat: 'yy/mm/dd'
}).datepicker("setDate", "08/03/2016");
Also tried >>
$('.datepicker').datepicker();
$('.datepicker').datepicker("setDate", "08/03/2016");
It highlight the current date if clicked but no set to text field. please help
Replacing your g:textField
with input works.
$("#admissionDate").datepicker(); $('#admissionDate').datepicker( "setDate", "10/12/2012" );
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"></script> <input type="text" id="admissionDate" class="form-control datepicker" name="admissionDate" style="width: 200px"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.