0

I have here a code snippet. Now, this isn't mine. I just found this in the internet that and I thought I could use it. Now the problem I ran into is.. I cannot select succeeding months but I do can select the current month. What should be done in here? Here is the link http://jsfiddle.net/jM9Wm/7/

Noticed that you can select the month of December after pressing enter.. But you cannot select any moths after it. Any idea?

Any help would be much appreciated. Thanks

Boy Pasmo
  • 8,021
  • 13
  • 42
  • 67

4 Answers4

3

If you only want to select the month and year you could use the solution shown here:

jQuery UI DatePicker to show month year only

Community
  • 1
  • 1
Bas van Dijk
  • 9,933
  • 10
  • 55
  • 91
  • Yea. But I have two different kind of datepicker in one page. One showing the full calendar and the other showing month and year only. – Boy Pasmo Dec 06 '13 at 07:57
2

You're actually hiding the calendar where today's date is already selected, hence the selection when you press enter, which only validates this date. Switching to another month doesn't change the selected date. So that's for enter.

But if you're looking to allow only month and year selection, the right way would be osi's answer.

Have a look at jsFiddle in comments (jsfiddle.net/x99UT).

Samuel
  • 2,106
  • 1
  • 17
  • 27
  • Yes. But what if I have two different kinds of datepicker in a single page. One showing the full calendar and one showing months and years only which I can then select. Think you can help me with this? – Boy Pasmo Dec 06 '13 at 08:04
  • Then the problem is in you first selector. You should have two calls, one for the two fields you want only month and year, and one for the field having full calendar. And you should define them by giving them different classes, like 'month-picker' and 'day-picker' for example. – Samuel Dec 06 '13 at 08:11
  • How? Think you can provide an example or a jsfiddle perhaps? – Boy Pasmo Dec 06 '13 at 08:13
0

jquery code

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script>
$(function() {
    $( "#news_date" ).datepicker({
        dateFormat: 'yy/mm/dd',
        changeMonth: true,
        changeYear: true,
        yearRange: "-100:+0"
        });
  });

i hope it will help you.

Govinda Rajbhar
  • 2,926
  • 6
  • 37
  • 62
0

just remove beforeshow function in your jquery snippets. there they have applied some conditions.

use the follwing...

$('input').datepicker();
Sathish RG
  • 112
  • 6