My client sells tickets/cruises, that sort of thing. Obviously, she can't sell them for years that have passed... Is there a way to remove past years from the date picker?
My client sells tickets/cruises, that sort of thing. Obviously, she can't sell them for years that have passed... Is there a way to remove past years from the date picker?
This is the datepicker that we use:
http://jqueryui.com/demos/datepicker/
Over on the right hand side, there are details on how to restrict the dates under Examples. You would want to put your JavaScript code for this in the header.php of your theme.
The datepicker is straight from the jQuery UI library so you can pass parameters in your theme header or script files to modify it.
http://docs.jquery.com/UI/API/1.8/Datepicker
This is probably what you're looking for
http://stackoverflow.com/questions/1786411/jquery-datepicker-to-prevent-past-date
$("#datepicker").datepicker({ minDate: 0 });
I've tried a few things, but none of them seem to work. Can anyone tell me what I'm doing wrong? Example: http://directconnexiontravel.com/?page_id=25
Can you try the following:
$(document).ready(function () {
$(".hasDatepicker").datepicker({ minDate: 0+ })
});
Doesn't seem to make any difference for me...
You have a syntax error in the JavaScript you pasted into the head:
Timestamp: 7/31/2012 1:56:26 AM
Error: SyntaxError: syntax error
Source File: http://directconnexiontravel.com/?page_id=25
Line: 39, Column: 47
Source Code:
$(".hasDatepicker").datepicker({ minDate: 0+ })
You will also soon have a "$ is not defined" error because $ is reserved for Prototype in WordPress. Please try this version:
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function () {
$j(".hasDatepicker").datepicker({ minDate: '0' })
});
</script>
There seems to be lots of conflicting information online of how to format the minDate:
http://stackoverflow.com/questions/1786411/jquery-datepicker-to-prevent-past-date
Other variations of this line you can try:
[js]
$j(".hasDatepicker").datepicker({ minDate: +0 })
[js]
$j(".hasDatepicker").datepicker({ minDate: 0, })
I've tried all of these syntax variations, but no luck so far. Thanks for trying, though.
Can you try changing it to .datepicker instead of .hasDatepicker just out of curiosity?