I am receiving the error:
Uncaught TypeError: undefined is not a function
When I try to set up the datepicker:
$('.datepicker').datepicker();
How can I determine if the datepicker has loaded or not?
To be clear, I'm not using jQuery UI
On the All tab of the Property Sheet, make sure the Show Date Picker property is set to For dates. On the Data tab of the property sheet, type =Date() in the Default Value property for the field. Note: If you want to include the current time as well as the date, use the Now() function instead of Date().
To disable a datepicker in jQuery UI we will be using disable() method which is discussed below: jQuery UI disable() method is used to disable the datepicker.
Initialize the datepicker and specify the date format in "yyyy-mm-dd". JavaScript Code : $( "#datepicker" ). datepicker(); $( "#datepicker" ).
You can check to see if the datepicker script has loaded using:
if ($.fn.datepicker) {
// ...
}
Then you can conditionally invoke the .datepicker()
method if the script has loaded:
if ($.fn.datepicker) {
$('.datepicker').datepicker();
}
Example Here
In doing so, the error won't be thrown if the script hasn't loaded.
You can also use:
if (typeof $().datepicker === 'function') {
$('.datepicker').datepicker();
}
Example Here
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