I want to show a datepicker only on button click
<input type="button" id=day value="day" />
$("#day").datepicker();
the above line fills the button text with the selected date
I have also tried with below code but nothing happens
$("#day").click(function() {
$("#hiddenField").datepicker('show');
});
A date-picker of jQuery UI is used to provide a calendar to the user to select the date from a Calendar. This date picker usually connected to a text-box so user selection of date from the calendar can be transferred to the textbox.
The JavaScript DatePicker (Calendar Picker) is a lightweight and mobile-friendly control that allows end users to enter or select a date value. It has month, year, and decade view options to quickly navigate to the desired date.
You can do this with the built-in showOn
function:
$( "#hiddenField" ).datepicker({
showOn: "button",
buttonText: "day"
});
JSFiddle: http://jsfiddle.net/Uv8V4/
Reference: http://jqueryui.com/datepicker/#icon-trigger
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With