Datepicker formats produces unpredictable results. You wanted the date format as dd/mm/yy like for example 01/06/2016 1st June 2016 (not 6th January 2016). Here's a simple solution.
First, set the header code below:
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
Then your HTML:
<input type="text" class="datepicker" name="bdate" id="bdate" value="">
Lastly, your javascript:
<script type="text/javascript">
$(document).ready(function(){
var val = $('#bdate').val();
$('#bdate').datepicker("option", "dateFormat", 'dd/mm/yy');
$('#bdate').datepicker( "setDate", val);
});
That's it.
Goodluck.
Walang komento:
Mag-post ng isang Komento