In my php-file, I want to use the jQuery Datepicker.
When my file loads, I create the Datepicker disabled.
Then, when a special field in my php-file (it is a
Well You can remove datepicker by simply remove hasDatepicker
class from input.
Code
$( "#from" ).removeClass('hasDatepicker')
This is what worked for me
$("#from").attr("disabled", true);
You can replace form field with its copy:
var copy = $('#from').clone();
$('#from').replaceWith(copy);
And after that initialize datetimepicker again.
Datepicker is disabled automatically when the input text field is made disabled or readOnly:
$j("#" + CSS.escape("${status.expression}")).datepicker({
showOn: "both",
buttonImageOnly: true,
buttonImage: "<c:url value="/static/js/jquery/1.12.1/images/calendar.gif"/>",
dateFormat: "yymmdd",
beforeShow: function(o, o2) {
var ret = $j("#" + CSS.escape("${status.expression}")).prop("disabled")
|| $j("#" + CSS.escape("${status.expression}")).prop("readOnly");
if (ret){
return false;
}
return o2;
}
});
$('#ElementID').unbind('focus');
did the trick for me !!
$("#datepicker").datepicker({
dateFormat:'dd/M/yy',
minDate: 'now',
changeMonth:true,
changeYear:true,
showOn: "focus",
// buttonImage: "YourImage",
buttonImageOnly: true,
yearRange: "-100:+0",
});
$( "#datepicker" ).datepicker( "option", "disabled", true ); //missing ID selector