I need to display initial value which selected from the database for the date text field.Im adding a date from jquery date picker. After I adding the jquery code Initial value does not show..Can anyone suggest me an answer? Thank you !
here is my jquery code
<script src="JDate/ui/jquery.ui.core.js"></script>
<script src="JDate/ui/jquery.ui.widget.js"></script>
<script src="JDate/ui/jquery.ui.datepicker.js"></script>
<link rel="stylesheet" href="JDate/demos/demos.css">
<script>
$(function() {
$( "#birthday_text" ).datepicker();
$( "#birthday_text" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
});
</script>
here is my textbox code
<input name="birthday_text" type="text" class="textfield" id="birthday_text" autocomplete="off" value="0000-00-00" readonly="readonly"/>
Initialize the default date when you attach the date picker as so:
$(function() {
$( "#birthday_text" ).datepicker( {defaultDate:"0000-00-00",dateFormat: "yy-mm-dd" });
});
jsfiddle with demo
Update : Since you say that the "defaultDate" parameter is giving you problems, try this alternative:
$( "#birthday_text" ).datepicker({dateFormat: "yy-mm-dd" } );
$( "#birthday_text" ).val('0000-00-00');
jsfiddle for alternative.
You'll want to set the default date with the options when you're setting the datepicker up. Check out their docs on default date: http://jqueryui.com/demos/datepicker/#option-defaultDate . Also, there is a chance that the datepicker control won't let you use 0000-00-00 since it isn't a valid date. Have you tried with something other than all zeros?
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.