I'm using a Jquery datepicker element which allows a user to select only months.
<style>
.ui-datepicker-calendar {
display: none;
}
</style>
The above css works fine. But I'm passing a variable that indicates whether the user is able to select only months or he can select date too. A kind of Conditional Styling.
The code goes something like this for me now.
<head>
<link rel="stylesheet" href="styles/jquery-ui.css" />
<script language="javascript" type="text/javascript" src="js/jquery.js" ></script>
<script language="javascript" type="text/javascript" src="js/jquery-ui.js"></script>
</head>
//some code here
<label for="myDate">myDate</label>
<input type="text" id="myDate" name="myDate" />
//some more code
if(//myTest - This is to test if only months are to be shown)
{
$(".ui-datepicker-calendar").css("display", "none");
$('#myDate').datepicker( {
changeMonth: true,
changeYear: true,
changeDate: false, // This parameter is just for trial. On cross-checking with jquery-ui.js, I found there's no such property. :(
showButtonPanel: true,
dateFormat: 'MM yy',
});
//$(".ui-datepicker-calendar").css({display: 'none'}); -- This didn't work either
}
else
{
//normal code for a jquery datepicker
}
});
Now, the above code is not giving me the required output. I need to execute:
$(".ui-datepicker-calendar").css("display", "none");
only if myTest in above code is true.
In other words, it is still showing the dates in the datepicker which I dont want to show.
Please help.