I am looking to set the default date format to ISO8601 yy-mm-dd
in my code. Currently, it switches back to the default option if I choose a different format and then go back. How can I ensure that ISO format is always selected by default when someone picks a date?
<script>
$(function() {
$("#datepicker").datepicker();
$("#format").on("change", function() {
$("#datepicker").datepicker("option", "dateFormat", $(this).val());
});
});
</script>
<p>
Date: <input type="text" id="datepicker" size="30">
</p>
<p>
Format options:<br>
<select id="format">
<option value="yy-mm-dd" selected>ISO 8601 - yy-mm-dd</option>
<option value="d M, y">Short - d M, y</option>
</select>