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

4
  • Do you want to select month alone? Commented Dec 6, 2013 at 7:53
  • Month and year would be nice.. Like how the dateFormat suggest: mm/y. Commented Dec 6, 2013 at 7:54
  • What is your desired output? Commented Dec 6, 2013 at 7:56
  • A two digit of month and year.. So when I choose December 2014.. The output would be 12/14. Like that Commented Dec 6, 2013 at 7:58

4 Answers 4

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.
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).

3 Comments

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?
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.
How? Think you can provide an example or a jsfiddle perhaps?
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.

Comments

0

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

use the follwing...

$('input').datepicker();

2 Comments

Thanks but. I have another datepicker in the same page showing months and years only.
add some class to other input. then use $('.theclassname').datepicker({dateFormat: 'yy/mm'}); please try this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.