Jquery datetimepicker time and date Control

Source: Internet
Author: User

In jquery UI, there is a control datepicker, which can only select a date. No time available. In this project, I encountered a problem where I had to display the date and time together. I searched the internet and found the datetimepicker time and date control.

He mentioned several bugs. Let me talk about it here. Because I also encountered the following problems:

1. When the input time in the input box is 0, the control is incomplete because of a Function Bug, as shown below:

Modify in the jquery-calendar.js file.

Trimnumber: function (value ){
If (value = '')
Return '';
While (value. charat (0) = '0 '){
Value = value. substring (1 );
}
Return value;
},

While (value. charat (0) = '0 '){
Value = value. substring (1 );
}

If it is 0, an error will always occur, because its length is 1 at last, and substring (1) cannot be executed. Just change it to the following:


Trimnumber: function (value ){
If (value = '')
Return '';
While (value. charat (0) = '0' & value. length> 1 ){
Value = value. substring (1 );
}
Return value;
},

--------------------------------------------------------------------------------

2. the original author is implemented in jquery1.1.2. The latest version is 1.4.2. This control has an exception in version 1.4.2 and cannot select a date, there are several selector problems: (I have read the Version 1.3.2 mentioned in the original article. The version 1.4.2 I used was changed according to this method, which can also be implemented)

It is also modified in the jquery-calendar.js file:

1 $ ('. calendar_daysrow TD [a]'). Hover (// highlight current day
2 function (){
3 $ (this). addclass ('calendar _ dayscellover ');
4}, function (){
5 $ (this). removeclass ('calendar _ dayscellover ');
6 });
7 $ ('. calendar_daysrow TD [a]'). Click (function () {// select day
8 popupcal. selectedday = $ ("A", this).html ();
9 popupcal. SelectDate ();
10 });

Above $ ('. calendar_daysrow TD [a] ') cannot be used in jquery 1.3.2, $ ("A", this) is also problematic, and in Firefox, the <A> cannot set the background color, so the hover function does not work. You can set it to <TD> to achieve the same effect, just change it to the following code:

1 // $ ('. calendar_daysrow TD A'). Hover (// highlight current day
2 $ ('. calendar_daysrow TD'). Hover (// highlight current day
3 function (){
4 $ (this). addclass ('calendar _ dayscellover ');
5}, function (){
6 $ (this). removeclass ('calendar _ dayscellover ');
7 });
8 // $ ('. calendar_daysrow TD [a]'). Click (function () {// select day
9 $ ('. calendar_daysrow TD A'). Click (function () {// select day
10 // alert ("click ");
11 // popupcal. selectedday = $ ("A", this).html ();
12 popupcal. selectedday = week (this).html ();
13 popupcal. SelectDate ();
14 });

--------------------------------------------------------------------------------

Uh .. I forgot to talk about it. To import jquery.js, jquery-calendar.js, and jquery-calendar.css files.

Here is an example in the original article can refer to :( http://razum.si/jQuery-calendar/TimeCalendar.html)

--------------------------------------------------------------------------------

3. I wrote a control for use on a separate page, but a layer popped up in my project cannot be used in the layer.

The reason is:

In fact, the control has come out. It is only blocked by the DIV that I popped out, and it will show no effect.

Modified the value of Z-index in the style "calendar_div" in the jquery-calendar.css file to be greater than the value of the displayed layer.

4. modify the format:

In the jquery-calendar.css file, there is a dateformat attribute that is originally mdy/shown as mm/DD/yy 00:00:00 AM.

Set it to 'ymd-'and it will be mm-dd-yy 00:00:00 AM.

Http://hi.baidu.com/waterjiang/blog/item/87a9e10152aea26c3912bb1e.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.