JQuery 1.32 DatePicker Enhanced resolves issue with end date less than start date

Source: Internet
Author: User
Tags getdate

The end date is less than the start date, you always have to code the problem, but it is convenient now, do not need to focus on the details of these issues

The following content is the original address: http://www.cnblogs.com/yasin/archive/2009/07/10/1520736.html

Add some JS code to implement the "clear" button

< script type = "Text/javascript" >
$ (function () {
$ ("#datepicker"). DatePicker ({closetext: ' X ', Showbuttonpanel:true, Showclearbutton:true, Mindate:new Date (20 09, 7, 10)});
});
</script >

Automatic selection of the date period:

< script type = "Text/javascript" >
$ (function () {

$ ("#start-date"). DatePicker (
{onselect:function (Datetext, inst) {$ (' #end-date '). DatePicker (' option ', ' mindate ', new Date (datetext.replace ( ' - ' , ' , ' )));}
});

$ ("#end-date"). DatePicker (
{onselect:function (Datetext, inst) {$ (' #start-date '). DatePicker (' option ', ' maxdate ', new Date (DATETEXT.REPL Ace ('-', ', ')));}
});
});
</script >

Application source code and more DatePicker examples of usage download:

/files/yasin/jquery_datepicker.zip

DatePicker Official Address:

Http://docs.jquery.com/UI/API/1.7/Datepicker#method-option

2009-07-13 increase focus lost after auto-Validate date format

_doblur:function (Event)
{
var inst = $.datepicker._getinst (event. Target);

if (inst.input[0].value.length = = 0)//allow NULL
return;

var reg =/^ (/d{4}) (//|-) (/d{1, 2})/2 (/d{1, 2}) $/;
var arr = inst.input[0].value.match (REG)
if (arr = = null)
{
Alert ("The wrong time format, please fill in format/n as: 2012-12-22");
var today = new Date (); Set to current date
inst.input[0].value = today.getyear () + "-" + (Today.getmonth () + 1) + "-" + today.getdate ();
inst.input[0].focus ();
return;
}
var tempdate = new Date (arr[1],arr[3]-1, arr[4]);
if ((tempdate.getfullyear () = = arr[1] && (tempdate.getmonth () + 1) = = arr[3] && tempdate.getdate () = = arr[4]) = = False)
{
Alert ("The wrong time format, please fill in format/n as: 2012-12-22");
var today = new Date (); Set to current date
inst.input[0].value = today.getyear () + "-" + (Today.getmonth () + 1) + "-" + today.getdate ();
inst.input[0].focus ();
return;
}
},

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.