I need to show jQuery UI datepicker on link click, also when a date is picked change link text to this date, how can I do it?
Syntax: $(". selector"). datepicker("show");
An optional initialEntryMode argument can be used to display the date picker in the DatePickerEntryMode. calendar (a calendar month grid) or DatePickerEntryMode. input (a text input field) mode. It defaults to DatePickerEntryMode.
jQuery UI date picker should do the job.
Check out the example using an icon to trigger the picker: http://jqueryui.com/demos/datepicker/#icon-trigger
You can also call the show() method to drop down the picker whenever you need to, e.g...
$('#mypicker').datepicker({
//options
minDate: '20.04.2012'
//...
});
$('#mylink').click(function(){
$('#mypicker').datepicker('show');
});
To change the link text after a date is selected, use something like this in initialization code:
$('#mypicker').datepicker({ onSelect:
function(dateText, inst) {
$('#mylink').text(dateText);
}
});
$("#dateField").datepicker({
dateFormat:'dd/M/yy',
minDate: 'now',
changeMonth:true,
changeYear:true,
showOn: "focus",
//buttonImage: "YourImage",
buttonImageOnly: true,
yearRange: "-100:+0",
});
$("dateField").datepicker( "option", "disabled", true );
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