最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Having two jQuery datepickers on the same page - Stack Overflow

programmeradmin7浏览0评论

I'm using Timepicker (extended Datepicker from jQuery UI here). My code:

$('.one').datepicker({
    dateFormat: "d"
});
$('.two').timepicker({
    timeFormat: "hh"
});

When I click on field .two, Firebug shows me an error:

Error parsing the date string: Unexpected literal at position 2

date string = 10

date format = mm/dd/yy

timepicker.js (line 1911)

Everything seems to work just fine, but I wonder why is this error showing up and how can I make it disappear?

EDIT: Actually my code looks like this:

$('.one').datepicker({
    dateFormat: "d m y"
});
$('.two').timepicker({
    timeFormat: "hh mm"
});

EDIT2: /

I'm using Timepicker (extended Datepicker from jQuery UI here). My code:

$('.one').datepicker({
    dateFormat: "d"
});
$('.two').timepicker({
    timeFormat: "hh"
});

When I click on field .two, Firebug shows me an error:

Error parsing the date string: Unexpected literal at position 2

date string = 10

date format = mm/dd/yy

timepicker.js (line 1911)

Everything seems to work just fine, but I wonder why is this error showing up and how can I make it disappear?

EDIT: Actually my code looks like this:

$('.one').datepicker({
    dateFormat: "d m y"
});
$('.two').timepicker({
    timeFormat: "hh mm"
});

EDIT2: http://jsfiddle/r9bCk/

Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Feb 17, 2013 at 11:08 Gury MaxGury Max 1612 silver badges15 bronze badges 8
  • can you show us more code? – Abubakkar Commented Feb 17, 2013 at 11:11
  • what is your expected date format? just 'd'? are you parsing this to date? – Sen Jacob Commented Feb 17, 2013 at 11:15
  • Try time format 'Hi' &instead of hh – Shridhar Commented Feb 17, 2013 at 11:16
  • I updated my post. That's my whole code. I don't do anything more. – Gury Max Commented Feb 17, 2013 at 11:21
  • I have a page with more than 5 timepickers (same jQuery UI plugin above), and they work perfectly. Try the code in jsfiddle to let us understand your problem. – AsemRadhwi Commented Feb 17, 2013 at 11:21
 |  Show 3 more ments

2 Answers 2

Reset to default 7

Gury, Try to include the addon v.1.1.0 from here, and hopefully it resolves the error. It's the same version I'm using. Clearly there's a bug in the new versions.

The error is ing from the timepicker plugin itself. It is there in the example link. See $('#basic_example_2').timepicker(); after a selection.

Use a previous stable version as AsemRadhwi suggested

发布评论

评论列表(0)

  1. 暂无评论